Re: reading expressions in a file
- To: mathgroup at smc.vnet.net
- Subject: [mg108208] Re: reading expressions in a file
- From: Raffy <adraffy at gmail.com>
- Date: Wed, 10 Mar 2010 06:29:05 -0500 (EST)
- References: <hn7ffp$341$1@smc.vnet.net>
On Mar 9, 10:50 pm, Maria Davis <arbi... at gmail.com> wrote: > Hi ; > > I have a file .txt generated from a software, each line of the file > includes an expression and the last line is empty. > How can Mathematica read lines of the text file and include each line > in the same list without reading the last empty line . > > I used : > MYLIST = ReadList["file.txt", Record, RecordSeparators -> {}] > > But it still reading the empty line. > > Thanks. ReadList["file.txt", Record, RecordSeparators -> {}] will just read the entire file as a single string. It sounds like you just want: ReadList["file.txt", String] Although, if any of other expressions are empty, they'll be ignored, so you could also use: Most@ReadList["/Users/raffy/Desktop/test.txt", String, NullRecords -> True]