From: Maria Davis on
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.

From: Raffy on
On Mar 9, 10:50 pm, Maria Davis <arbi...(a)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(a)ReadList["/Users/raffy/Desktop/test.txt", String, NullRecords ->
True]

From: dh on
Hi Maria,
simply set the option: "IgnoreEmptyLines" -> True
Daniel

On 10.03.2010 07:50, Maria Davis 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.
>


--

Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh(a)metrohm.com>
Internet:<http://www.metrohm.com>