这些是CSV文件的内容 -
altitudeAscent,altitudeDescent,altitudeavg,altitudecurrent,altitudeend,altitudemax,altitudemin,altitudestart,卡路里,类名,createAppVersion,CreateDevice的,createIOSVersion,距离,eaType,ecomodule,elapsedSeconds,fatCalories,footpodElapsedSecondsInterval,gpsSensor,gps_distance,gps_maxspeed,heartSensor,isCompletedAssessment ,isLocationIndoors,isgpsonly,maxBPM,MAXSPEED,:MINBPM,otherWorkoutTypeName,otherzonetimes,primarySourceSpeedDistance,readCountBPM,routineds,routineid,startLat,startLon,开始时间,totalBeats,totalDurationSeconds,totalPausedSeconds 0,2.37,-999999,33.66,33.66,42.76,28.21,36.47,410.08,ActiveWorkout, 7.00 下,iPhone5,1,7.0,0.27,0,1024,2657 ,207.77,2655,ios,0.27,3.69,ble,NO,NO,YES,186,3.69,87,举重,85,全球定位系统,884,4.000000,TEMP-1663889272,37.10730362,-76.50557709,2013-08-26T18 :48:21,110056,0,0
我需要从CSV文件中删除“7.00”值。我如何在VB或C#中做到这一点?
答案 0 :(得分:3)
string names;
List<string> values;
using (var stream = new StreamReader("path/to/file.csv"))
{
names = stream.ReadLine();
values = stream.ReadLine().Split(',').ToList();
}
values.RemoveAt(9);
names; // first part of file
string secondPartOfFile = string.Join(",", values);
答案 1 :(得分:1)
答案 2 :(得分:1)
这对我有用
var sr = new StreamReader("file.csv");
var writeToFile = new StreamWriter("out.csv");
string line;
while ((line = sr.ReadLine()) != null)
{
writeToFile.WriteLine(sr.ReadLine().ToString().Replace(",7.00", ""));
}
writeToFile.Close();
sr.Close();