Bookmark and Share

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

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

st: importing quirky csv

From   Douglas Levy <>
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.

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

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
1                       ,1                       ,2,20111007
     ,11:39:23                ,RYG - Carvery Special,Carvery
1                       ,1                       ,2,20111007
     ,11:39:23                ,RYG - Yellow,Salad Bar

*   For searches and help try:

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