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)

CodePudding user response:

reference 1/X - I - n reply:
 
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)
what do you think what is my file coding

CodePudding user response:

reference 1/X - I - n reply:
 
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)
copies of your code, the prompt writeline not a member of the file

CodePudding user response:

System. IO. File. WriteAllText (" new file path. TXT ", STRB. Tostring (), System. Text. The Encoding. The UTF8)
Hand slide typo,

Notepad to open the document, you can see that code, or use a certain code read is garbled, when this code is wrong, in another,

CodePudding user response:

X
refer to 4th floor - I - n reply:
System. IO. File. WriteAllText (" new file path. TXT ", STRB. Tostring (), System. Text. The Encoding. The UTF8)
Hand slide typo,

Notepad to open the document, you can see that code, or use a certain code read is garbled, when this code is wrong, in another,

Dare ask this line will give a return value what lines ah, just learning is not very good

CodePudding user response:

X
refer to 4th floor - I - n reply:
System. IO. File. WriteAllText (" new file path. TXT ", STRB. Tostring (), System. Text. The Encoding. The UTF8)
Hand slide typo,

Notepad to open the document, you can see that code, or use a certain code read is garbled, when this code is wrong, in another,
the transformed data not line, all in a row

CodePudding user response:

STRB. Append (string. Join (", ", the columns) +
No break gave him a ah
  • Related