Click here to Skip to main content
15,921,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

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.
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900