Streamreader跳过CSV文件的开头

时间:2018-11-14 04:18:17

标签: c# csv streamreader

我正在尝试从文件将CSV数据打印到控制台。我可以通过Console.Writeline打印它,但是它仅从第58行数据打印。我不知道为什么它不是从#1开始的。请帮忙!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

class Program
{
    public static void Main()
    {
        string currentDirectory = Directory.GetCurrentDirectory();
        DirectoryInfo directory = new DirectoryInfo(currentDirectory);

        var fileName = Path.Combine(directory.FullName, "Louisville_KY_Metro_Parks.csv");

        var fileContents = Readfile (fileName);
        Console.WriteLine(fileContents);
    }

    public static string Readfile(string fileName)
    {
        using (var reader = new StreamReader(fileName))
        {
            return reader.ReadToEnd();
        }
    }
}

数据:

OBJECTID,PARK_NAME,PARK_ACRE,REGION,OPS_DIST,PARK_TYPE,OLMSTED,PARK_WEB,SHAPEAREA,SHAPELEN,FULLADDR,PUBLIC_,RESTROOM,CONFERENCE,PICNIC,CAMPING,SWIMMING,HIKING,FISHING,PLAYGROUND,GOLF,SOCCER,BASEBALL,BASKETBALL,FOOTBALL,TENNIS,HORSEBACK,VOLLEYBALL,WALKING,MULTIFIELD,SPRAYPADS,SPRAYGRND,COMMUNITY,SPECIAL,SKATEPARK
1,35TH STREET,0.43194602,,NORTHWEST,NEIGHBORHOOD PARK,NO,https://louisvilleky.gov/government/parks/park-list/35th-street-park,18815.49355,640.565031823698,814 SOUTH 35TH ST,,,,,,,,,YES,,,,YES,,,,,,,,,,,
2,CRESCENT HILL,7.63689681,,CREASON,COMMUNITY PARK,NO,https://louisvilleky.gov/government/parks/park-list/crescent-hill-park,332661.894521875,3106.34455651455,3110 BROWNSBORO RD,,,,YES,,YES,,,YES,YES,,,,,YES,,,,,,YES,,MARY T MEAGHER AQUATIC CENTER,

0 个答案:

没有答案