Loading [MathJax]/jax/input/TeX/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >fread EOF而不是分隔符

fread EOF而不是分隔符
EN

Stack Overflow用户
提问于 2016-02-20 02:27:05
回答 2查看 3.2K关注 0票数 1

我试图用fread读取一个大文件,但我猜文件的布局有问题。

如果我尝试用以下命令读取文件

代码语言:javascript
运行
AI代码解释
复制
data = fread(input = "../data.txt", sep = "\t")

在这个文件中(我只取了包含错误的那一行,以及之前和之后的几行):

代码语言:javascript
运行
AI代码解释
复制
ID  imdbID  Title   Year    Rating  Runtime Genre   Released    Director    Writer  Cast    Metacritic  imdbRating  imdbVotes   Poster  Plot    FullPlot    Language    Country Awards  lastUpdated Type
683 tt0000683   The Fatal Hour  1908        14 min  Short, Crime    1908-08-18  D.W. Griffith   D.W. Griffith   George Gebhardt, Harry Solter, Linda Arvidson, Florence Auer        5.9 26      Pong Lee, a Mephistophelian, saffron-skinned varlet, has for some time carried on this atrocious female white slave traffic, in which sinister business he was assisted by a stygian whelp, ... Pong Lee, a Mephistophelian, saffron-skinned varlet, has for some time carried on this atrocious female white slave traffic, in which sinister business he was assisted by a stygian whelp, by name Hendricks. Pong writes Hendricks that he has need for five young girls, and so Hendricks sets out to secure them. Visiting a rural district, he has no trouble, by his glib, affable manner, in gaining the confidence of several young and pretty girls. Pong is on hand with a closed carriage to bag the prey. One of the girls, as she is seized, emits a yell that alarms the neighborhood and brings to the scene several policemen and a couple of detectives, who have long been on the lookout for these caitiffs. The Chinese get away with the carriage, however, and Hendricks by subterfuge throws the police on the wrong scent. One of the detectives is a woman, and possessed of shrewd powers of deduction, hence does not swallow the bald story of the villain, and exercises her natural acumen with success. She shadows Hendricks, and by means of a flirtation inveigles him to a restaurant, where she succeeds in doping his drink. He falls asleep and she secures the letter written by Pong, which discloses the hiding place of the Chinaman. This she immediately telephones to the police, and while so doing Hendricks awakes and starts off to warn his friends. He arrives at the old deserted house ahead of the police, but escape is impossible, so the police rescue the girls, but fail to secure Pong and Hendricks, who afterwards seize the girl detective, and taking her to the house, tie her to a post and arrange a large pistol on the face of a clock in such a way that when the hands point to twelve the gun is fired and the girl will receive the charge. Twenty minutes are allowed for them to get away, for the hands are now indicating 11:40. Certain death seems to be her fate, and would have been had not an accident disclosed her plight. Hendricks after leaving the place is thrown by a street car, and this serves to discover his identity, so he is captured and a wild ride is made to the house in which the poor girl is incarcerated. This incident is shown in alternate scenes. There is the helpless girl, with the clock ticking its way towards her destruction, and out on the road is the carriage, tearing along at breakneck speed to the rescue, arriving just in time to get her safely out of range of the pistol as it goes off. In conclusion we can promise this to be an exceedingly thrilling film, of more than ordinary interest.    English USA     2015-10-24 01:44:09.623000000   movie
684 tt0000684   Father Gets in the Game 1908        10 min  Short, Comedy   1908-10-10  D.W. Griffith   D.W. Griffith   Mack Sennett, Harry Solter, George Gebhardt, Linda Arvidson     5.1 39      "You have got to keep up with the bandwagon or quit." This never impressed old Wilkins so forcibly as when his son and daughter give him the go-by, stamping him as a "has-been," and away ...  "You have got to keep up with the bandwagon or quit." This never impressed old Wilkins so forcibly as when his son and daughter give him the go-by, stamping him as a "has-been," and away out of the game. Even Mrs. Wilkins, who is as vivacious as a widow, snubs him. He keenly feels his condition and resolves to alter it. With this in view, he enlists the services of Professor Dyem, the celebrated Dermatologist and Tonsorial Artist. After a session with the Professor, beheld the transmogrified Wilkins. What a change! Shorn of his grizzly beard, his locks raven, complexion florid, eye clear and step elastic, he views himself in the mirror. He hardly recognizes himself. In fact, it requires his valet to convince him that he is he. "Am I in it? Well. I guess. If I don't keep up with and even beat that bandwagon by a city block, my name is not Pill Wilkins." He sallies forth and makes for the park. The first person he encounters is his wife. He approaches her in elation, but she mistakes him for an impudent masher and he receives the weight of her parasol over his head for his trouble. The next one he meets is his daughter. She is seated on a bench, waiting for Charley. He takes a seat beside her and when he tries to make himself known she draws herself up to full height and with a blow sends him backward over the bench onto the grass. Well, he changes his tactics, and gets reckless. Along comes his son with his best girl, so he decides to win her out for spite. Now this young lady has a sensitive pneumogastric nerve, and when he sits beside her on the bench and slyly suggests a cold bottle and a hot bird, she is "his'n." This is done so coolly and so quickly, that young Wilkins, who, of course, does not recognize his respected papa, is speechless with rage. He follows them, however, to the café, where his intrusion is resented and he is rudely thrown from the place. At the Wilkins' domicile there is an indignation meeting. Mother, daughter and son all rush in to relate their experiences to father. He is not to be found. Suddenly a hilarious individual enters. "'Tis he, the insulter: a drunk and disorderly." They are about to have him thrown out when the valet comes to his rescue and explains that the jubilant gentleman is no other than their dear papa, who has not only caught up with the bandwagon, but is sitting on the seat with the driver. They all gasp in surprise, and young Wilkins takes a wreath of laurel from a statue and places it on old Wilkins' brow, saying: "Pop, you are the candy."    English USA     2015-10-02 04:59:48.643000000   movie
685 tt0000685   The Feud and the Turkey 1908        15 min  Short, Drama, Romance   1908-12-08  D.W. Griffith   D.W. Griffith   Harry Solter, Linda Arvidson, Arthur V. Johnson, Robert Harron      5.8 13      The Wilkinsons and Caulfields, owing to a trivial dispute, had been at loggerheads for years and as time went on the feeling became more bitter, until they even forbade their children ... The Wilkinsons and Caulfields, owing to a trivial dispute, had been at loggerheads for years and as time went on the feeling became more bitter, until they even forbade their children playing together. The little ones, however, in their childish innocence, could not appreciate the odium of their elders, and Bobby Wilkinson and Nellie Caulfield became child lovers. This incensed Colonel Wilkinson, who tore the children apart, ordered Bobby never to be seen in her company again. The Colonel's action ignited the ire of the Caulfields and a furious conflict ensued, resulting in the shooting to death of George, the Colonel's youngest son, a boy of fourteen. From that time on the clans kept strictly to themselves. But love knows no clannishness, and, despite family hatred, Bob and Nellie remained lovers. After ten years, driven to desperation by this apparently insurmountable barrier, they elope and are married. Bob decides to brave the storm of his father's anger and present his wife, but the old Colonel drives him from the house, disowning him. Old Aunt Dinah and Uncle Daniel, the colored servants, were so attached to the young folks that they go with them. Two years later we find the little family, now increased by an infant son, having a hard of it. It is Christmas morning and no turkey for dinner. Old Aunt Dinah, believing in the efficacy of prayer, gets down on her knees in the kitchen to ask the good Lord to send them a bird. Uncle Daniel, touched by this demonstration of faith, takes a gun and determines to get a turkey at any hazard. Over the hills he goes, but his journey is hopelessly fruitless until he comes to the rear of the Colonel's house. Tillie, the cook, has just hung a fat turkey on a post outside the kitchen door. When Daniel sees it he can't resist the temptation. Back home he hustles and finds Dinah still at prayer, he lays the fowl on the floor beside her and sneaks out. When Dinah sees it she surely thinks it was due to her prayers. Well, the turkey is cooked and an old-fashioned Christmas anticipated. Meanwhile the Colonel has discovered his loss and tracks the thief to Bob's estate. Entering, a tragedy seems inevitable, but when the old Colonel sees the young one, his grandson, in the cradle, his heart goes out to it and the feud ends then and there. All hands sit down and enjoy a real Merry Christmas dinner. English USA     2015-08-29 00:33:15.610000000   movie
686 tt0000686   Fiestas del carnaval de 1908 en Barcelona   1908            Documentary, Short      Fructuós Gelabert   Fructuós Gelabert                                   Spain       2015-11-09 14:24:29.583000000   movie

我得到了这个错误:

代码语言:javascript
运行
AI代码解释
复制
>     Error in fread(input = "../data.txt", sep="\t"  :    Expected sep ('  ') but new line, EOF (or other
> non printing character) ends field 20 when detecting types (   first):
> 684   tt0000684   Father Gets in the Game 1908        10 min  Short,
> Comedy    1908-10-10  D.W. Griffith   D.W. Griffith   Mack Sennett, Harry
> Solter, George Gebhardt, Linda Arvidson       5.1 39      "You have got to keep
> up with the bandwagon or quit." This never impressed old Wilkins so
> forcibly as when his son and daughter give him the go-by, stamping him
> as a "has-been," and away ...     "You have got to keep up with the
> bandwagon or quit." This never impressed old Wilkins so forcibly as
> when his son and daughter give him the go-by, stamping him as a
> "has-been," and away out of the game. Even Mrs. Wilkins, who is as
> vivacious as a widow, snubs him. He keenly feels his condition and
> resolves to alter it. With this in view, he enlists the services of
> Professor Dyem, the celebrated Dermatologist and Tonsorial Artist.
> After a session with the Professor, beheld the transmogrified Wilkins.
> W

我该怎么解决它呢?

EN

回答 2

Stack Overflow用户

发布于 2016-12-20 12:22:46

在这里,我不能100%确定数据中的错误是什么,但请尝试使用以下命令运行代码

代码语言:javascript
运行
AI代码解释
复制
data = fread(input = "../data.txt", sep = "\t", fill = TRUE)

在fread选项中。我也遇到了类似的错误,似乎fread在识别我的列分隔时遇到了麻烦。将fill设置为true允许fread填充任何丢失的数据-至少这样您就可以检查结果数据框并找出奇怪的地方。

票数 4
EN

Stack Overflow用户

发布于 2018-06-13 07:19:49

在语法中添加fill = TRUE

发生了什么:数据中的行的长度不相等。使用此语法时,将隐式填充空白字段。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35518401

复制
相关文章
EOF是不是字符
百度百科上这样解释:EOF是一个计算机术语,为End Of File的缩写,在操作系统中表示资料源无更多的资料可读取。资料源通常称为档案或串流。通常在文本的最后存在此字符表示资料结束。
老齐
2020/07/23
4.6K0
EOF是不是字符
何时使用MongoDB而不是MySql
MySQL 和 MongoDB 是两个可用于存储和管理数据的数据库管理系统。MySQL 是一个关系数据库系统,以结构化表格格式存储数据。相比之下,MongoDB 以更灵活的格式将数据存储为 JSON 文档。两者都提供性能和可扩展性,但它们为不同的应用场景提供了更好的性能。
wayn
2023/08/09
1.1K0
何时使用MongoDB而不是MySql
何时使用Kafka而不是RabbitMQ
Kafka 和 RabbitMQ 都是流行的开源消息系统,它们可以在分布式系统中实现数据的可靠传输和处理。Kafka 和 RabbitMQ 有各自的优势和特点,它们适用于不同的场景和需求。本文将比较 Kafka 和 RabbitMQ 的主要区别,并分析何时使用 Kafka 而不是 RabbitMQ。
wayn
2023/06/26
4330
何时使用Kafka而不是RabbitMQ
何时使用Elasticsearch而不是MySql
MySQL 和 Elasticsearch 是两种不同的数据管理系统,它们各有优劣,适用于不同的场景
wayn
2023/08/28
3820
何时使用Elasticsearch而不是MySql
何时使用Kafka而不是RabbitMQ
Kafka 和 RabbitMQ 都是流行的开源消息系统,它们可以在分布式系统中实现数据的可靠传输和处理。Kafka 和 RabbitMQ 有各自的优势和特点,它们适用于不同的场景和需求。本文将比较 Kafka 和 RabbitMQ 的主要区别,并分析何时使用 Kafka 而不是 RabbitMQ。
wayn
2023/08/28
3320
何时使用Kafka而不是RabbitMQ
何时使用Elasticsearch而不是MySql
MySQL 和 Elasticsearch 是两种不同的数据管理系统,它们各有优劣,适用于不同的场景。本文将从以下几个方面对它们进行比较和分析:
wayn
2023/08/09
8000
何时使用Elasticsearch而不是MySql
fread函数_fread读取数据到数组
文章迁移: fread函数详解 – 码到城攻fread函数详解,C函数使用注意事项,fread
全栈程序员站长
2022/09/30
1.1K0
fread函数_fread读取数据到数组
C语言fread函数_C语言fread
The prototype of the function fread() is:
全栈程序员站长
2022/10/02
23.5K0
C语言fread函数_C语言fread
做产品经理而不是功能经理
产品经理是个很奇怪的岗位,好像大多数人都能做,因为每个人对某个产品都有自己的看法,都能提出一些意见和想法,甚至能设计实现原理;也好像大多数人都做不好产品经理,因为互联网上成千上万个产品,大部分是垃圾,
用户1756920
2018/06/20
1.2K0
android推荐使用dialogFrament而不是alertDialog
DialogFragment在android 3.0时被引入。是一种特殊的Fragment,用于在Activity的内容之上展示一个模态的对话框。典型的用于:展示警告框,输入框,确认框等等。 在DialogFragment产生之前,我们创建对话框:一般采用AlertDialog和Dialog。注:官方不推荐直接使用Dialog创建对话框。 2、 好处与用法 使用DialogFragment来管理对话框,当旋转屏幕和按下后退键时可以更好的管理其声明周期,它和Fragment有着基本一致的声明周期。且Dia
xiangzhihong
2018/01/29
2.5K0
android推荐使用dialogFrament而不是alertDialog
WideNet:让网络更宽而不是更深
这是新加坡国立大学在2022 aaai发布的一篇论文。WideNet是一种参数有效的框架,它的方向是更宽而不是更深。通过混合专家(MoE)代替前馈网络(FFN),使模型沿宽度缩放。使用单独LN用于转换各种语义表示,而不是共享权重。
deephub
2023/08/30
2400
WideNet:让网络更宽而不是更深
云原生关乎文化,而不是容器
本文译自 Cloud-Native Is about Culture, Not Containers[1],文章洋洋洒洒上万字,作者总结了她见过的云原生失败的各种经验教训,还用生动的示例说明了什么不是云原生。译者是在周末闲暇时间仓促间翻译的,其中难免有不当之处,请读者指正。译者:宋净超(Jimmy Song)
xcbeyond
2021/04/02
5260
C++fread小解
1 std::size_t fread( void* buffer, std::size_t size, std::size_t count, std::FILE* stream );
用户7886150
2021/02/12
7630
Spring Boot 容器选择 Undertow 而不是 Tomcat
Spring Boot内嵌容器支持Tomcat、Jetty、Undertow。为什么选择Undertow?
lyb-geek
2022/03/09
1.9K0
使用HSB而不是RGB来定义颜色
有多种方法可以在代码中定义颜色。最常用的方法是指定三种基色的值 - 红色、绿色和蓝色 (RGB)。本文通过指定色调、饱和度和亮度 (HSB) 的值来探索替代机制的使用。可以以更直观的方式使用 HSB 属性来创建颜色搭配良好的调色板。
韦弦zhy
2023/01/06
2.8K0
使用HSB而不是RGB来定义颜色
a标签点击后下载图片而不是打开
如果遇到图片等格式是会直接打开,如果我们需要这种也维持下载的话,加个download属性即可
阿超
2022/08/16
2.2K0
重要的是图表思维,而不是工具
很久没有作图了,主要是一时找不到应该练手的案例。 然后昨天逛网易数独栏目的数据新闻,看到一幅还不错的案例,对于我来说值得一试,然后就手痒给照葫芦画瓢弄出来了。(主要是其中涉及到的细节处理很麻烦) 当然过程是花了些时间的,主要是需要慢慢打磨其中的细节,需要利用很多技术来处理图形版面的交接位置。 令我感触最深的是,想要用ggplot2随心所欲的画图,ggplot2掌握的再熟练,也只是勉强过的了技术关,而图表背后的思维和结构更考验人,更具有挑战性。 好在我学习R语言之前,就已经利用Excel临摹了大量的高难度信息
数据小磨坊
2018/04/11
9630
重要的是图表思维,而不是工具
innodb为什么选择B+ Tree而不是跳表,Redis为什么选择跳表而不是B+ Tree
链表和数组相比,数组可以通过下标快速定位,或者通过二分查找,查询复杂度为O(logn),而链表只能按照顺序挨个查找,复杂度为O(n)。
大忽悠爱学习
2023/03/23
2.5K0
innodb为什么选择B+ Tree而不是跳表,Redis为什么选择跳表而不是B+ Tree
html 转换为cshtml,使用Html而不是csHtml
我想使用纯HTML页面而不是使用MVC .net的cshtml . 但是当我通过右键单击索引添加视图时,我只能看到两个选项 .
全栈程序员站长
2022/09/10
2.6K0
需要学习的是编程,而不是编程语言
我们不仅是程序员,而且是个(与时俱进的)学习者。鲜见的是有多少人认为他们是在学习编程的呢。原翻译传送门is here
Jimmy_is_jimmy
2023/05/24
5130

相似问题

当不是eof时,fread返回零

20

使用EOF进行fread时出错?

09

获取文本而不是EOF

31

Python而不是recordset.EOF而不是.MoveNext

11

期望eof,而不是eof附近的任意数据

10
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档