List:MySQL on Win32« Previous MessageNext Message »
From:<jbonnett Date:August 25 2005 11:51pm
Subject:RE: Loading data into a single from a number of text files
View as plain text  
I think something like 

copy *.csv all.csv

will end up concatenating the files too.

To do jobs like this I usually end up writing some VB code to massage
the data through to MySQL. I have written Access procedures that open
Excel sheets via automation and send their data into linked tables in
MySQL. The sheets can be more complex than simple CSV tables too, as the
program logic can navigate around the sheets and pick up the data needed
and perform any filtering, reformatting etc. that might be required.

John Bonnett
Computer Scientist
Carl Zeiss Vision GmbH
Lonsdale, South Australia
Phone: +61 8 8392 8366
Fax: +61 8 8392 8400

-----Original Message-----
From: SGreen@stripped [mailto:SGreen@stripped] 
Sent: Thursday, 25 August 2005 11:43 PM
To: Daniel da Veiga
Cc: MySQL Win32 List
Subject: Re: Loading data into a single from a number of text files

FWIW, the DOS command you would use to create one file by concatenating 
several files would be the COPY command.

This is from a Win2K command prompt but I can remember using the 
concatenation form as far back as DOS 2.06 (on a PC Jr.)

C:\>copy /?
Copies one or more files to another location.

COPY [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B]
     [+ source [/A | /B] [+ ...]] [destination [/A | /B]]

  source       Specifies the file or files to be copied.
  /A           Indicates an ASCII text file.
  /B           Indicates a binary file.
  destination  Specifies the directory and/or filename for the new 
file(s).
  /V           Verifies that new files are written correctly.
  /N           Uses short filename, if available, when copying a file
with 
a
               non-8dot3 name.
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /-Y          Causes prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.  Default is
to prompt on overwrites unless COPY command is being executed from
within a batch script.

To append files, specify a single file for destination, but multiple
files
for source (using wildcards or file1+file2+file3 format).


Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine


Daniel da Veiga <danieldaveiga@stripped> wrote on 08/25/2005 11:09:41
AM:

> On 8/24/05, Pranav Lal <pranav.lal@stripped> wrote:
> > Daniel,
> > <snip That's a good solution, if that doesn't work, you can always
> > build a
> > batch to do that, you can use cat and redirect to concatenate all
> > files within a directory into one, then rename the file as the table
> > name and import it, this way you wouldn't mess with your files
> > (because you would only "cat" them) and could build a daily big file
> > with the content of all the others.
> > PL] I am on Windows XP. I understand that cat is a unix command? I
> > understand that the equivalent command on Windows is type?
> > 
> > Pranav
> > 
> > 
> 
> Geesh, I'm getting banged with all this OSs switching here at the job,
> yeah, yeah, its "type", didn't realized... Blame me if you use Linux
> and Win and never did an "ls" at the DOS prompt :)
> 
> Sorry,
> 
> -- 
> Daniel da Veiga
> Computer Operator - RS - Brazil
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.1
> GCM/IT/P/O d-? s:- a? C++$ UBLA++ P+ L++ E--- W+++$ N o+ K- w O M- V-
> PS PE Y PGP- t+ 5 X+++ R+* tv b+ DI+++ D+ G+ e h+ r+ y++
> ------END GEEK CODE BLOCK------
> 
> -- 
> MySQL Windows Mailing List
> For list archives: http://lists.mysql.com/win32
> To unsubscribe:
http://lists.mysql.com/win32?unsub=1
> 
Thread
Loading data into a single from a number of text filesPranav Lal24 Aug
  • Re: Loading data into a single from a number of text filesFelix Geerinckx24 Aug
    • Re: Loading data into a single from a number of text filesDaniel da Veiga24 Aug
Re: Loading data into a single from a number of text filesDaniel da Veiga25 Aug
  • Re: Loading data into a single from a number of text filesSGreen25 Aug
    • Re: Loading data into a single from a number of text filesDaniel da Veiga25 Aug
RE: Loading data into a single from a number of text filesjbonnett26 Aug