我有一个程序,可以导出csv文件,但不会引用新行或使用/n
而不是/n/r
。它在记录的中间使用与末尾相同的行尾。该程序确实使用变量之间的逗号分隔符。我如何告诉R
删除所有的eol标记,直到达到数据中的变量数目?R有没有办法加入csv文件的虚线?
我的数据是这样的:
name, rank, serial number, age, height, weight
mike, noob, 123456, 22, 6, 34.4
bob, officer, 345
323, 24, 6, 2
3.5
ted, officer, 34234, 2
5, 6, 35.2
我怎么会基本上在2行中的5后3行,第6行2之后删除CR,2个后?每行应该有5个逗号和6个变量。我的数据在每行之间没有额外的行。我只是无法停止将它全部放在一条线上,而没有这样做。我的数据是43个变量,并不断产生新的行。大多数情况下,阅读时有几千行。其中约20%有CR问题。
此外,还希望添加一个新行将始终在新行开始,它不会跟在前一行,如果这是有道理的。
数据帧应该是这样的:
name, rank, serial number, age, height, weight
mike, noob, 123456, 22, 6, 34.4
bob, officer, 345323, 24, 6, 23.5
ted, officer, 34234, 25, 6, 35.2
这是我的数据是什么样子没有什么帮助。第一行是一个标题,后面是6条记录,但是read.csv
和fread
以及我尝试过的所有内容都给出了10条记录。第6条记录有额外的CR,但仍有42个变量。刚分解成5行。
EFPCName,EFUseAPPE,log pdl,pdl error,device pretty name,num pages,num sheets,copies printed,total pages printed,total sheets printed,total color pages printed,total bw pages printed,total tab pages printed,total sample pages printed,num copies,print status,instructions,notes1,notes2,username,noneutf8lastuser,non utf8 submitted by,title,size,logical printer,fiery,time,date,total rip duration,timestamp spooling,timestamp done spooling,timestamp waiting to rip,timestamp ripping,timestamp done ripping,timestamp waiting to print,timestamp printing,timestamp done printing,media weight,input slot,media size,media type,interpreter,
LZX Laser 24 - 11 x 17 Tabloid,,postscript,,Canon,2,1,1,2,1,1,1,0,0,1,OK,,,,TeamMember,,TeamMember,78053.01.pdf,4004491,Canon hold,SERVER-Shredder,2013 06 07 19 37 13,2013 06 07 19 37 00,3,2013 06 07 19 37 23,2013 06 07 19 37 24,2013 06 07 19 38 02 118342,2013 06 07 19 38 02 118342,2013 06 07 19 38 09,2013 06 07 19 38 09,2013 06 07 19 38 38,2013 06 07 19 39 19 124419,,Tray5,Tabloid,Plain,PS,
LZX Laser 24 - 11 x 17 Tabloid,,postscript,,Canon,2,1,1,2,1,1,1,0,0,1,OK,,,,TeamMember,,TeamMember,78053.01.pdf,4004520,none,SERVER-Shredder,2013 06 07 19 37 13,2013 06 07 19 37 00,,2013 06 07 19 44 07 926090,2013 06 07 19 44 07 926744,2013 06 07 19 44 07 926090,2013 06 07 19 44 07 926090,2013 06 07 19 44 07 926744,2013 06 07 19 44 07,2013 06 07 19 44 11,2013 06 07 19 44 53 141084,,Tray5,Tabloid,Plain,PS,
LZX Laser 24 - 11 x 17 Tabloid,,postscript,,Canon,2,1,1,2,1,1,1,0,0,1,OK,,,,TeamMember,,TeamMember,78053.01.pdf,4004520,none,SERVER-Shredder,2013 06 07 19 37 13,2013 06 07 19 37 00,,2013 06 07 19 46 01 550964,2013 06 07 19 46 01 551451,2013 06 07 19 46 01 550964,2013 06 07 19 46 01 550964,2013 06 07 19 46 01 551451,2013 06 07 19 46 01,2013 06 07 19 46 05,2013 06 07 19 46 46 911557,,Tray5,Tabloid,Plain,PS,
LZX80 Color Copy Cover - 11 x 17 Tabloid,,postscript,,Canon,1,2,2,2,2,2,0,0,0,2,OK,,,,TeamMember,,TeamMember,78011.01.pdf,874486,Canon hold,SERVER-Shredder,2013 06 07 19 47 07,2013 06 07 19 47 00,3,2013 06 07 19 47 17,2013 06 07 19 47 17 507576,2013 06 07 19 47 47 960542,2013 06 07 19 47 47 960542,2013 06 07 19 47 51,2013 06 07 19 47 51,2013 06 07 19 47 54,2013 06 07 19 48 25 77595,,Tray3,Tabloid,Heavy5,PS,
LZX Laser 24 - 11 x 17 Tabloid,,postscript,,Canon,2,1,1,2,1,1,1,0,0,1,OK,,,,TeamMember,,TeamMember,78053.01.pdf,4004520,none,SERVER-Shredder,2013 06 07 19 37 13,2013 06 07 19 37 00,,2013 06 07 19 48 04 501212,2013 06 07 19 48 04 502522,2013 06 07 19 48 04 501212,2013 06 07 19 48 04 501212,2013 06 07 19 48 04 502522,2013 06 07 19 48 04,2013 06 07 19 48 07,2013 06 07 19 48 48 188474,,Tray5,Tabloid,Plain,PS,
EX32 Laser 32 - 11 x 17 Tabloid,,pdf,,Canon,63,64,1,63,64,4,59,0,0,1,OK,Size: 11 x 17
Finishing: Coil Binding Cutting Punching
Pages:
1-63 4/0 EX32 Laser 32 - 11 x 17 11 x 17
,Color 77992:01Employee Handbook REVISED_2up(NFC).pdf, McAllen TX,EFI Pace,,,Color 77992:01Employee Handbook REVISED_2up(NFC).pdf,518880,none,SERVER-Shredder,2013 06 07 20 01 52,2013 06 07 20 01 00,3,2013 06 07 20 02 41 495216,2013 06 07 20 02 44 780196,2013 06 07 20 02 41 871208,2013 06 07 20 02 41 871208,2013 06 07 20 02 45,2013 06 07 20 02 45,2013 06 07 20 03 25,2013 06 07 20 05 45 741386,,Tray4,Tabloid,Heavy1,PS,
我得到这个错误:错误if(dat [k] ==“”){:缺少值,其中TRUE/FALSE需要 另外:有50个或更多的警告(使用警告()看到前50 )。这也正在阅读和显示一个闪亮的应用程序。用户无法干预。如果确实有某种问题,是否可以折腾?我还没有看到那样做,但我猜可能是可能的。 –
如果k> length(dat),可能会发生此错误。 – nya
@MichaelCiesielczyk它是否在datal表中创建了一些与您的真实数据正确识别的行? – nya