读取文件时如何转义文本文件的某些行? [英] how to escape certain line of a text file while reading files ?

查看:87
本文介绍了读取文件时如何转义文本文件的某些行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在读取csv文件的内容.它的工作正常,但我在这里有条件.我的实际内容从文件的第二行开始(第一行包含一些信息,例如文件的标题").
我想逃避忽略这一行,并从第二行开始阅读.我已经搜索了一段时间,但找不到确切的解决方案.请帮忙.

i am working on reading contents of a csv files. its working fine but i have a condition here. My actual contents start from the second line of file(first line contains some info say "TITLE of the file").
i want to escape neglect this line and start reading from the second line. i have been searching for a while but could not find the exact solution. Please help.

推荐答案

如果使用的是StreamReader,只需调用一次ReadLine()而不检查结果.
如果需要将Stream与其他代码一起使用,则可以:
If you are using a StreamReader, just call once ReadLine() without checking the result.
If you need to use the Stream with some other code, you can:
StreamReader sr = new StreamReader(stream);
sr.ReadLine();//will advance the stream cursor to the next line


之后,从流中读取代码将从下一行开始.


After that, code reading from stream will begin at the next line.


这篇关于读取文件时如何转义文本文件的某些行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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