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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSV to CSV data transfer 1

Status
Not open for further replies.

moolie

Programmer
Joined
May 7, 2002
Messages
193
Location
CA
I have 6 CSV/TXT files generated by Access 2000 dump to a folder. I need to open each and copy/append the data into one master csv/txt file. I am able to get this to happen but what I am getting in additional "" marks around string data:
original csv:

"BA",1000.00,"HARVEST OPERATIONS CORP",,"#2200, 400 - 3RD AVENUE S.W.",,,"CALGARY, AB","T2P 4H2","","","13102


master csv

"""BA""",1000.00,""HARVEST OPERATIONS CORP"",,""#2200, 400 - 3RD AVENUE S.W."",,,""CALGARY, AB"",""T2P 4H2"","""","""","13102

Any suggestions on how to eliminate the additional quotation marks and append the lines from one file into another without loosing data, adding quotes or changing the data in anyway?
 
I would say that the easiest way and probably the fastest is to issue a DOS copy command
e.g.
copy file1.csv+file2.csv+file3.csv masterfile.csv

If the masterfile already exists the following will also work.

type file1.csv >>masterfile.csv

These are the non VB solutions, but probably the fastest ones.

VB solution to follow...




Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
It sounds like you are using INPUT and WRITE to read and write the records. They are field based operations but what you really want here are line-based operations. Try reading the records with

Open "SourceFile" For Input As #nIn
Line Input #nIn, strText

and appending them to the output file with

Open "DestFile" For Append As #nOut
Print #nOut, StrText
 
Both methods work well. I would like to use code to eliminate a Batch file. The csv files have multiple records and I'm not sure how to configure the loop. any suggestions.
 
dim ninfile as integer
dim noutfile as integer
ninfile = FreeFile()
noutfile = FreeFile()

open "destfile" for append as noutfile

Open "file1.csv" For Input As ninfile
While Not EOF(ninfile)
Line Input #ninfile, StrText
Print #noutfile, StrText
Wend
Close ninfile

Open "file2.csv" For Input As ninfile
While Not EOF(ninfile)
Line Input #ninfile, StrText
Print #noutfile, StrText
Wend
Close ninfile

close noutfile


Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Kick ASS !

works wonderfully! Thanks you guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top