我需要改變我的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'就結了? –
我正在爲他添加一個澄清編輯。請耐心等待。我破解了代碼! :) –