我需要改变我的CSV文件的格式。如何重新格式化CSV文件?
我的CSV文件:
x,a,b,c
e,,2,1
f,3,15,
g,7,8,9
所需格式:
ea0
eb2
ec1
fa3
fb15
fc0
ga7
gb8
gc9
我写代码,但它不工作:
string log = retval(textBox1.Text, 0, 512);
string[,] head = new string[4, 4];
int row=0;
int column=0;
string[] lines = log.Split('\n');
foreach (string l in lines)
{
string[] split = l.Split(',');
foreach (string item in split)
{
head[row, column] = item;
column++;
}
row++;
}
for (row=1; row < 4; row++)
{
string tmp = "";
for (column = 1; column < 4; column++)
{
tmp = head[row, column];
}
listBox1.Items.Add(tmp);
}
这种格式背后的逻辑是不是clear.Why你想要这个格式以及如何手动创建这种格式。 – Innovation
你想要的“EA0”,“EB2”值'listBox1'就结了? –
我正在为他添加一个澄清编辑。请耐心等待。我破解了代码! :) –