在CSV行的末尾找到未终止的带引号的字段 [英] Finding Un-terminated quoted field at end of CSV line

查看:140
本文介绍了在CSV行的末尾找到未终止的带引号的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何,我们是否可以找到"CSV行结尾的带引号的未终止字段"的行号?我正在尝试用Java读取CSV文件,但最有可能出现错误,因为-有一个引号已打开但未关闭.我正在使用deeplearning4j的CSVRecordReader-datavec.

Is there anyway we could find line number of "Un-terminated quoted field at end of CSV line"? I'm trying to read CSV file in java, but getting error most probably because - there is a quote is opened but isn't closed. I'm using CSVRecordReader of deeplearning4j - datavec.

这个想法是,如果我找到该行号,则可以删除/更正它.但是问题是,抛出错误时我找不到行号.

The idea is that if I find that line number, I can remove/correct it. But problem is, I can not find the line number when error is thrown.

如果您有任何建议-用Java或其他语言,请告诉我.谢谢!

If you have any suggestion - in Java or other, please let me know. Thanks!

推荐答案

对于datavec,我会考虑使用调试器.您可以轻松地在以下位置设置断点: https://github.com/deeplearning4j/deeplearning4j/blob/master/datavec/datavec-api/src/main/java/org/datavec/api/records/reader/impl/csv/CSVRecordReader.java#L181 ,看看它在哪里无法解析文件.

For datavec, I would consider using a debugger. You could easily put a breakpoint on: https://github.com/deeplearning4j/deeplearning4j/blob/master/datavec/datavec-api/src/main/java/org/datavec/api/records/reader/impl/csv/CSVRecordReader.java#L181 and see where it fails to parse the file.

您也可以只编写自己的RecordReader.建议替代性csv库的人没有完整的上下文,所以让我将其重定向到该库的适当解决方案:您说它紧密集成,但是您实际上误解了它所耦合的 where

You could also just write your own recordreader instead. The person suggesting the alternative csv library didn't have the full context, so let me redirect this to a proper solution to the library: You say it's tightly integrated, but you're actually misunderstanding where it's coupled.

您可以使用任何所需的记录读取器.您不必使用我们提供的服务.这些组件仅在接口级别耦合.

You can use any recordreader you want. You don't have to use the ones we provide. The components are coupled at an interface level only.

关于您的特定csv问题,您也可以清理csv文件.我的解决方案专注于尝试在您的ide中对其进行调试.

On your particular csv problem, you could also just clean up the csv file. My solution was focused on trying to debug it within your ide.

无论哪种方式,您都可以在此处为解决方案提供多种选择.如果您对可用性有特殊建议,也非常欢迎您提出问题: https://github.com/deeplearning4j/deeplearning4j/issues

Either way, you have multiple options for a solution here. If you have a particular suggestion on usability, you are more than welcome to file an issue as well: https://github.com/deeplearning4j/deeplearning4j/issues

这篇关于在CSV行的末尾找到未终止的带引号的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆