Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating New CSV files from a master 1

Status
Not open for further replies.

ftpdoo

Programmer
Aug 9, 2001
202
GB

I have a csv file (C:\test.csv) in the following format:

Requested Action Code,17,17
Requested Action Code,18,18
Requested Action Code,19,19
Requested Action Code,20,20
Requested Action Code,21,21
Meter Period Number,01,01
Meter Period Number,02,02
Meter Period Number,03,03
Meter Period Number,04,04
Meter Period Number,05,05
Meter Period Number,06,06
Actual/Estimated Indicator,A,A
Actual/Estimated Indicator,C,C
Actual/Estimated Indicator,E,E

Every time the first column changes i want to create a new CSV file containing only the columns 2 and 3. Then naming the new CSV file the value in the first column.

ie: Requested Action Code.csv will contain:

17,17
18,18
19,19
20,20
21,21

Meter Period Number.csv wil contain:

01,01
02,02
03,03
04,04
05,05
06,06

Any help would be appricated,

Jonny
 
What have you got so far?

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
I have my VB app but to add this functionality in im not sure.. I presume i need to parse the file first and then compare the first column each time?

Not sure how to do this.. Thought there might be a quicker way of doing all this??

Jonny
 
if you search these forums you will find plenty of examples that show how to open a file, loop through it, and outputing to a file.

Should be easy to incorporate that into your application.

But you do need to search and get here with your code, not just ask us to to it for you, specially on such a simple code that has so many examples laying around

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
I have this data in Oracle at the moment and was going to export to a CSV file to parse in VB. Do you think it would be quicker to export to Access or try and write something in SQL to do this??

Any advice would be appricated.. (before i jump in with both feet and wish i hadn't!) :-/

Thanks in advance,
Jonny
 
Oracle may be able to do what you need directly. Ask on the Oracle group for that.


As for VB, it is a very easy loop through a recordset, writing to a new file on change of field.

There was a similar thread just a few days ago. see thread709-1135979.

But do search the forums for possible better solutions.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top