Combine two different csv files into one

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
TS
Newbie
Posts: 4
Joined: Fri Feb 05, 2010 7:17 am

Combine two different csv files into one

Post by TS » Sat Feb 06, 2010 11:03 pm

or add the content of one csv file into the next one.

I am sure this has been discussed already:

- I have tables from different webpages, which I received using table2clipboard (Thanks and greetings to Bob Hansen, here.)
- now they need to be added to an existing csv-file format, despite that they have different headers

This is actually a request for the basic handling of columns in csv files - avoiding Excel. Some columns need to be combined into one (like a; f; c; k; l; m etc.), others must be erased. It would not matter, to change the header directly in that finished file or to write into an existing one.

Any hints or links here welcome.

User avatar
JRL
Automation Wizard
Posts: 3518
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sun Feb 07, 2010 5:27 am

A good place to start might be SQL. Marcus has posted several great blogs about creating and modifying CSV files using SQL.

Look HERE for some possibilities.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sun Feb 07, 2010 11:33 pm

Have you considered using RegEx> ?

Can you provide a sample of some lines before parsing and desired results after?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

TS
Newbie
Posts: 4
Joined: Fri Feb 05, 2010 7:17 am

Some lines

Post by TS » Mon Feb 08, 2010 1:42 pm

Well, this makes a rather difficult read I suppose or can one add an attachment, which I haven`t found out so far?
To answer the question, no I had not considered RegEx so far, since I mainly need to shift whole columnes. At least in this very first table. But having had a closer look at the next tables, I found out I might should do so, since one these tables has all the information (address of customer and order) crammed into a single field, divided only by headwords, so to speak.



item-name listing-id sku price shipping-fee quantity-purchased total-price purchase-date batch-id buyer-email buyer-name
Selbstwert und Kommunikation. Familientherapie für Berater und zur Selbsthilfe 0113G0I7X8V PSY1006N 8 3 1 11 30.01.2010 10:31:37 Europe/Berlin [email protected] Donald Duck
Pustekuchen! Lauter kulinarische Wortgeschichten [Taschenbuch] by Gutknecht... 1117EU2DW61 BEL62029N 2,2 3 1 5,2 30.01.2010 11:39:39 Europe/Berlin [email protected] Donald Duck
Der große Schlaf [Taschenbuch] by Chandler, Raymond; Ortlepp, Gunar 0113G0I7C0P KRI9701N 0,85 3 1 3,85 30.01.2010 18:16:23 Europe/Berlin [email protected] Donald Duck


Artikel Gesamtsumme der Bestellung E-Mail-Adresse des Käufers Kunde
Autor: Herman-Friede, Eugen Titel: Für Freudensprünge keine Zeit Erinnerungen an Illegalität und Aufbegehren 1942-1948 EUR 3,95 [email protected] Marcus PilarskiVVN-BdA e.V.
Autor: Titel: Schleswig-Holsteinischer Heimatkalender 1966 EUR 5,50 [email protected] christiane bösche
Autor: Bongiorni, Sara Titel: Ein Jahr ohne Made in China EUR 14,00 [email protected] Christian Golbs

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Feb 09, 2010 1:50 am

I was hoping to see a BEFORE and AFTER example showing the same data. The two "paragraphs" in the previous posting do not appear to be that.

If the info above is data in columns, what is the delimiter between the columns? Is it a Tab or s SPACE char or something else? Can you use another character like "_" or "~" if the forum has trouble displaying them? Display it in both the BEFORE and AFTER examples.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

TS
Newbie
Posts: 4
Joined: Fri Feb 05, 2010 7:17 am

Post by TS » Tue Feb 09, 2010 5:29 pm

ZVAB Bestellnr.~Bestelleingang~Artikel

5789047~8. Februar 2010 00:25:44~Autor: Herman-Friede, Eugen Titel: Für Freudensprünge

5787952~7. Februar 2010 18:39:32~Autor: Titel: Schleswig-Holsteinischer

This is the header of the file to be imported, the delimiter is TAB, which I have replace with ~. I inserted empty lines to make it more obvious, where each line starts and ends. They are in columns, which I have shortened to explain how each file is built.

The first file looks very much the same, delimiter is also TAB. Thanks for any hint how to best tackle this one.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Feb 09, 2010 6:46 pm

Still trying to clarify your needs:

Is this correct (using "~" for tabs)?

File 1:
ID~Date~Author~Publisher~Subject~Pages
123~12/27/1988~Fred~MacMillan~History~356
2345~02/13/2003~Mary~O'Reilly~Computers~87

File 2:
ID~Date~Pages~Subject:Author
437~07/23/2001~55~Marketing:Sally

Need to modify File 2 to have format like File 1 and append to the end of File 1?
---------------------------------------------
If yes, then we can use RegEx to move the positions of the File 2 data, and insert blank field as needed for the missing Publisher to make it the same format as File 1. Then just append File2 to File 1.

If No, then still need clarification of the problem.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts