1
我想删除具有特定值的列。下面的代码是我用来删除一行的代码。我可以将其撤消以删除列吗?使用c删除CSV文件中的列#
int row = comboBox1.SelectedIndex;
string verw = Convert.ToString(txtChange.Text);
List<string> lines = new List<string>();
using (StreamReader reader = new StreamReader(System.IO.File.OpenRead(filepath)))
{
string line;
while ((line = reader.ReadLine()) != null)
{
if (line.Contains(","))
{
string[] split = line.Split(',');
if (split[row] == kill)
{
//achter split vul je de rij in
}
else
{
line = string.Join(",", split);
lines.Add(line);
}
}
}
}
using (StreamWriter writer = new StreamWriter(path, false))
{
foreach (string line in lines)
writer.WriteLine(line);
}
什么是标准来选择列删除?索引?这种看起来像你已经开始修改代码做你想做的事情,但你卡住了。这是否准确? – JuanR
你是什么意思删除列? –
我想要使用的标准是索引或列的名称(如果可能的话)。是的,我卡住了 – Mylan