Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Thomas, Anthony" <anthony_h_thomas@brown.edu> |
To | statalist@hsphsun2.harvard.edu |
Subject | st: Re: Bizzare return code in Mata |
Date | Mon, 17 Mar 2014 08:54:54 -0400 |
Also if it is helpful, here is the code up to that point: get = fopen("`1'", "rw") line = "HI" while(strlen(line) <= `3'){ line = fgetnl(get) } t = tokeninit("", ",", `""""') tokenset(t, line) variables = tokengetall(t) variables = select(variables, strmatch(variables, ","):!=1) variables[`2'] = char(select(ascii(variables[`2']), ascii(variables[`2']):!=34)) variables[`2'] = "#!!@$*&!&" + variables[`2'] variables = invtokens(variables, ",") ---> This is where error happens fseek(get, 0, 1) whereAmI = ftell(get) On Mon, Mar 17, 2014 at 8:48 AM, Thomas, Anthony <anthony_h_thomas@brown.edu> wrote: > Hi All, > > I need Stata to always import certain columns of a set of CSV files as > string. Insheet (Stata 11 - Unix) does not provide any options for > coercing variables to string so I wrote a small Mata utility which > appends some non-numeric characters to the first observation in a > specified column, copies the observation to the end of the file, > insheets the data (which will now be read as string) and then > truncates the file before the new line to restore the file to its > original status. > > In one CSV (the program works fine for all others), the call fseek(fh, > 0, 1) to seek the end of the file, aborts with the error r(1458296728) > - Stata returned error. I strongly suspect this is not a valid return > code... Also I'm a bit confused as to why Stata needs to be involved > at all. I assumed Stata called Mata's file routines, not the other way > around. Stata will happily insheet the file, and a hexdump of its > contents reveals no irregularities. Does anyone have any suggestions > as to what to look for or why I am getting this strange return code? > > Thanks, > > Anthony * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/