Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: importing quirky csv


From   Douglas Levy <[email protected]>
To   [email protected]
Subject   st: importing quirky csv
Date   Thu, 24 Nov 2011 08:51:16 -0500

I have a large number of large comma-separated text files that I am
trying to import. "insheet" is not working; it imports the data, but
many lines are missing. I think the reason is the file contains string
fields that a) have embedded spaces, and b) are not enclosed in
quotes. The string fields are not uniform in length. What is the best
way to import such a file? I've included the variable names and the
first 5 lines of the file below. It is important that the importation
method be something that does not require manipulation of the .csv
file outside of Stata because there are a large number of files to
import and I need to be able to automate it all within a do-file.
Thanks!

Variable names:  rvc term_id trans_nbr date_txt time maj_grp fam_grp
item_nbr item_name item_price item_wgt trans_seq menu_item_seq
check_seq

Sample data, as is:

1                       ,1                       ,2,20111012
     ,06:46:48                ,RYG - Weight - BFast,Salad Bar
B,130002,B-Fast Bar,5.60,0.390,8232096,1007,8206654
1                       ,1                       ,2,20111012
     ,06:46:48                ,RYG - Green,Hot Beverage B+L+D,50005,16
ozs Coffee,1.50,0.000,8232096,876,8206654
1                       ,1                       ,2,20111007
     ,11:39:23                ,RYG - Green,Carvery
L+D,400007,Spinach,1.25,0.000,8211986,1369,8186585
1                       ,1                       ,2,20111007
     ,11:39:23                ,RYG - Carvery Special,Carvery
L+D,370017,ChixPrm+Pst+Sauc,5.95,0.000,8211986,1308,8186585
1                       ,1                       ,2,20111007
     ,11:39:23                ,RYG - Yellow,Salad Bar
B+L+D,160508,Butter,0.10,0.000,8211986,1073,8186585

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index