LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2010)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 28 Aug 2010 08:10:40 -0400
Reply-To:     Art@DrKendall.org
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Art Kendall <Art@DrKendall.org>
Organization: Social Research Consultants
Subject:      Re: Read in mutliple .csv files
Comments: To: David Millar <david.millar@erc.ie>
In-Reply-To:  <8F90D613454DF941A55269BDF42B128242910CD395@ex2007-svr>
Content-type: text/plain; charset=ISO-8859-1; format=flowed

if there is information in each file identifying it, and you are not using the convention of having the first line be variable names, or if you feel it is not worthwhile to know which station produced the file and if you are using windows.

Put all the .csv file in a folder at the root of a device, e.g., c:\allcsv or J:\allcsv. open the command prompt. cd J:\allcsv copy *.csv combo.asc rename combo.asc combo.csv

read in combo.csv to SPSS.

Art Kendall

On 8/27/2010 12:57 PM, David Millar wrote: > Dear All > > I have about 100 data files for 100 stations - all with the same variables (I hope). I've used a macro to do this sort of thing before and I need to do something similar this time. My problem is that where I've done it before I've had nice, friendly file names like file1.csv, file2.csv etc. This time the file names are all strings - some with spaces (and that is really throwing me) like PARKVIEW LANE.csv, MILLWOOD.csv, NEWCASTLE ON WYE.csv. > > So the following works for one file - > > > GET DATA /TYPE = TXT > > /FILE = 'C:\dmillar\PARKVIEW LANE.csv' > > /DELCASE = LINE > > /DELIMITERS = "," > > /ARRANGEMENT = DELIMITED > > /FIRSTCASE = 2 > > /IMPORTCASE = all > > /VARIABLES = name a20 id_code a8 county a20 province a20 monthly_n f10. > > SAVE OUTFILE = 'C:\dmillar\PARKVIEW LANE.sav'/ > > KEEP=all. > > > However, I can't work out how to iterate it. I've tried > > > DEFINE !bring (!POSITIONAL !CHAREND ('/')). > > !DO 1 !TO 112 > > GET DATA /TYPE = TXT > > /FILE =!QUOTE(!CONCAT("C:\dmillar\",!1,".csv")). > > /DELCASE = LINE > > /DELIMITERS = "," > > /ARRANGEMENT = DELIMITED > > /FIRSTCASE = 2 > > /IMPORTCASE = all > > /VARIABLES = name a20 id_code a8 county a20 province a20 monthly_n f10. > > SAVE OUTFILE=!QUOTE(!CONCAT("C:\dmillar\",!1,".sav")). > > EXECUTE. > > !DOEND. > > !ENDDEFINE. > > > > !bring 'PARKVIEW LANE','MILLWOOD','NEWCASTLE ON WYE'/ > > > > Any help would be very much appreciated. > > > > Regards > > > > David > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD >

===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD


Back to: Top of message | Previous page | Main SPSSX-L page