I\'m having troubles trying to read a .txt file consisting of 561366 rows and 15 columns. The first rows look something like this:
70000||Consumer A||23||D
Methinks the sep=
character has to be of length one. So you could simply call either an external command (like sed
or perl
) to substitute the two-character ||
, or do it yourself in R.
Here is a proof of concept one-liner that first switches the ||
to ,
(and as |
is a meta character we need to escape it, and escape the escape character \
too):
R> read.csv(textConnection(gsub("\\|\\|", ",", "70000||Consumer A||23||DN||70000||10038782||1||SI||2||NO||0||N/A||0||N/A||1\n90000||Consumer B||23||DN||90000||15402432||1||SI||2||NO||0||N/A||0||N/A||1")), header=FALSE)
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15
1 70000 Consumer A 23 DN 70000 10038782 1 SI 2 NO 0 N/A 0 N/A 1
2 90000 Consumer B 23 DN 90000 15402432 1 SI 2 NO 0 N/A 0 N/A 1
R>
or maybe more legible in two lines:
R> txt <- "70000||Consumer A||23||DN||70000||10038782||1||SI||2||NO||0||N/A||0||N/A||1\n90000||Consumer B||23||DN||90000||15402432||1||SI||2||NO||0||N/A||0||N/A||1"
R> read.csv(textConnection(gsub("\\|\\|", ",", txt)), header=FALSE)
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15
1 70000 Consumer A 23 DN 70000 10038782 1 SI 2 NO 0 N/A 0 N/A 1
2 90000 Consumer B 23 DN 90000 15402432 1 SI 2 NO 0 N/A 0 N/A 1
R>