Dear Christian,

Well... it shouldn't normally do that. The only way I can currently think of that might cause this problem is that the file has \r\n\r\n, which would mean that every line is followed by an empty line.

Another cause might be (although I would not really expect the results you see) that the sum of your column widths is larger than the actual with of the line.

You can check your line lengths using:

lines <- readLines(my.filename)
nchar(lines)

Each line should have the same length and be equal to (or at least larger than) sum(my.column.widths)

If this is not the problem: would it be possible that you send me a small part of your file so that I could try to reproduce the problem? Or if you cannot share your data: replace the actual values with nonsense values.

Regards,
Jan

PS I read your mail by chance as I am not a regular r-help reader. When you have specific LaF problems it is better to also cc me directly.

On 08/06/2013 12:35 PM, christian.kame...@astra.admin.ch wrote:
Dear all

I was trying the (fairly new) LaF package, and came across the following 
problem:

I opened a connection to a fixed width ASCII file using
laf_open_fwf(my.filename, my.column_types, my.column_widths, my.column_names)

When looking at the data, it turned out that \n (newline) and \r (carriage 
return) were considered as characters, thus destroying the structure in my data 
(the second column does not include any numbers):

my.data[1565:1575,1:3]

    MF_FARZ1              Fahrzeugarttext MF_MARKE
1     \n043 Landwirt. Traktor                2140
2     \n043 Landwirt. Traktor                6206
3     \n001 Personenwagen                    2026
4     \n001 Personenwagen                    2026
5    \r\n00 1Personenwagen                    404
6    \r\n02 0Gesellschaftswagen               710
7    \r\n00 1Personenwagen                    505
8    \r\n00 1Personenwagen                    505
9    \r\n00 1Personenwagen                    301
10   \r\n00 1Personenwagen                    553
11   \r\n04 3Landwirt. Traktor                257

I am working on Windows 7 32-bit.

Any help would be highly appreciated.

Best Regard

Christian Kamenik
Project Manager

Federal Department of the Environment, Transport, Energy and Communications 
DETEC
Federal Roads Office FEDRO
Division Road Traffic
Road Accident Statistics

Mailing Address: 3003 Bern
Location: Weltpoststrasse 5, 3015 Bern

Tel +41 31 323 14 89
Fax +41 31 323 43 21

christian.kame...@astra.admin.ch<mailto:christian.kame...@astra.admin.ch>
www.astra.admin.ch<http://www.astra.admin.ch/>


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to