处理CSV文件 [英] Processing a CSV File

查看:97
本文介绍了处理CSV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个csv文件可供阅读,没有阅读和处理它的问题。见下表;



S / N名称等级工资点税

1保罗2 123 56 3.0

2 Pius 3 334 65 3.0

3珍妮特4 605 5.0 3.0

4琼斯5 445 5.7 3.0

5 Cyrus 6 545 0.9 3.0

6 Carla 7 678 66 3.0







问题:在提交数据库之前,如何将Salary列中的605和545相加。



那么如何处理CSV文件中的Tax列中的3.0和3.0总和。



文件结构更复杂但是如果我能做到这一点,我相信我能够完成它。



欢迎所有的建议。谢谢。

Hello Y'all,

I have a csv file to read through, no problem about reading through and processing it. see table below;

S/N Name Grade Salary Point Tax
1 Paul 2 123 56 3.0
2 Pius 3 334 65 3.0
3 Janet 4 605 5.0 3.0
4 Jones 5 445 5.7 3.0
5 Cyrus 6 545 0.9 3.0
6 Carla 7 678 66 3.0



The Question: How can I sum the the 605 and 545 on the Salary column before commiting to the database.

Then how can I sum 3.0 and 3.0 in the Tax column with processing the CSV file.

The file structure is more complex than this but If I can get how to do this, I believe I will be able to complete it.

All suggestions are welcomed. Thanks.

推荐答案

将文件读入DataTable / DataSet后,将所需行中的值转换为相应的numeric数据类型。将它们一起添加到另一个变量中并使用所述变量来更新数据库。
After you read the file into a DataTable/DataSet, convert the values in the rows you want to the appropriate numeric datatype. Add them together into another variable and use said variable to update the database with.


处理此类信息的一种方法是将数据导入数据库端的原始表。 />
然后将原始数据移动到登台表,然后移动到实际表格,将数据移动到登台表时对数据进行任何更改。



我建议在将数据导入数据库时​​不要操纵数据 - 如果要在读取和写入数据之间转换数据,将很难找到任何数据问题。



另外一般指导原则是在没有数据副本的情况下永远不更改客户数据 - 因此将数据导入原始表格可以保持此指南。
One way to process this sort of information is to import the data into raw tables at the database side.
Then to move the raw data to staging tables and then on to the actual tables making any changes to data when moving data into the staging tables.

I would recommend against manipulating the data while importing it into the database – it is going to be very difficult to find any data issues if you are transforming the data between reading and writing it.

Also a general guideline is to never change client data without having a copy of that data – so importing the data into the raw tables maintains this guideline.


这篇关于处理CSV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆