Home > Software engineering > VB.NET read the file into an array, the array changes into new CSV file
VB.NET read the file into an array, the array changes into new CSV file
Time:02-07
CodePudding user response:
Dim lines as string ()=System. IO. File. ReadAllLines (" File path. TXT ", System. Text. The Encoding. The UTF8) 'the code according to the actual situation to here, such as System. Text. The Encoding. GetEncoding (" GBK "), 'System. Text. Encoding. The Default, wrong coding will be garbled
Dim STRB as new stringbuilder For each line as a string in lines Dim the columns as string ()=Split (line, ", ") 'data manipulation... STRB. Append (string. Join (", ", the columns)) Next
System. IO. File. WriteLine (" new File path. TXT ", STRB. Tostring (), System. Text. The Encoding. The UTF8)