Questions tagged [read.fwf]

25 questions
0
votes
0 answers

Parsing Part of a file that is fixed width

I've got a file that is fixed width in the first half and table delimited by "," in the second half. When I copy part of the file and save as another file, the python function pandas.read_fwf(file_path) works perfectly as read_fwf can infer column…
0
votes
2 answers

Is there a function in R to separate .txt files with no delimiter?

I have been given a dataset as a .txt format that I need to import in R for a research analysis. The .txt file has one column with numeric characters, no header, and no delimiter. These are a couple of the examples in the .txt file:…
LillyA
  • 1
  • 1
0
votes
1 answer

How to read in multiple txt files at once and combine to one df using R?

I have 160 text files all with the same data columns, but no headers. There is no delimiter so I have to use read.fwf, I can read one in at a time using this code: myfile= "//PATH/AllFiles/10914_1Mile_TextFile.txt" read_fwf(myfile,…
Brian Gal
  • 13
  • 2
0
votes
1 answer

readr read_fwf strange parsing error: embedded null

I am trying to use readr::read_fwf to read-in a .txt file. I know all of the column widths but I receive this parsing error which I do not know how to resolve: fwf_widths <- c(12, 2, 6, ...) fwf_names <- c("V1", "V2", "V3", ...) col_types <-…
JRR
  • 578
  • 5
  • 21
0
votes
2 answers

R: read fwf file with missing final column

I am attempting to parse a fixed-width .txt files with readr's read_fwf. There are ~1.5 million observations and approx. 550 of them are missing the final 25 of 60 variables. This omission leads to the inperfect parsing of the final variable that…
JRR
  • 578
  • 5
  • 21
0
votes
0 answers

Loading fixed-width dataset into R, losing half of the columns

I am importing a .txt fixed-width dataset with 16 columns in R, and am losing ~half of the columns upon read. Hard to create replicable data but some ss/snippets below: Quick look at data below. The first screeenshot shows what the top half of the…
0
votes
1 answer

R: How to read fixed width datafile where the data is concatenated into two sets, stacked on top in one file

Hopefully the title make sense. In essence, there are two datasets in one file. Row 1 has the headings, by loc, for dataset1. Then lines 2-1500 are the entries for those locs. At row 1501 is the heading, by loc, for dataset2. Then lines 1502-3001…
Union find
  • 7,759
  • 13
  • 60
  • 111
0
votes
0 answers

Reading specific columns from a fixed width format file

I have large fixed width format dataset with multiple records with record number 1, 2, 3 and so on. I want to read all those records where record number is 1 using the select * sql statement. I'm using read.fwf function to import from the file but…
0
votes
1 answer

R Importing several fwf into one dataframe

I am trying to create a DF from 11 files in .txt (fwf) format and want to use apply. I have checked and found some good advice for read.csv, but not for fwf (as you have to specify the widths) This is how my data looks like: AA F AD PR PA POSICION T…
Pladiona
  • 93
  • 8
0
votes
1 answer

R readr::read_fwf ignore characters using fwf_widths

I would like to know if there is an easy way to skip characters using the read_fwf from the readr package in R. For example, modifying one of the examples in the documentation library(readr) fwf_sample <- system.file("extdata/fwf-sample.txt",…
lucacerone
  • 9,859
  • 13
  • 52
  • 80
1
2