怎样把txt文件中的数据导出成csv文件(在线等,多谢)

shinebxc 2006-10-10 11:47:41
txt文件中的数据按如下格式排列:
data1 data2 data3
1234 2345 3456
5678 6789 7890
列之间没有逗号, 由于数据文件过大,手工加逗号会死人的
有什么方法可以实现?
...全文
376 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
shinebxc 2006-10-10
  • 打赏
  • 举报
回复
LS的能写点注视么,多谢
leongwong 2006-10-10
  • 打赏
  • 举报
回复
Dim FS As New FileSystemObject, TS As TextStream
Dim TxtRows As Integer, Txt_Content As String
Dim jsq As Integer
Dim Str_Content As String
TxtRows = 5

Set TS = FS .OpenTextFile(App.Path + "\*.txt", 1)

For jsq = 1 To TxtRows
Txt_Content = Trim(TS.ReadLine)
If InStr(1, UCase(Txt_Content), "要判断的字符=") <> 0 Then
Str_Content= Mid(Txt_Content , InStr(1, UCase(Txt_Content), "要判断的字符=") + 13, Len(Txt_Content))
End If
Next jsq
shinebxc 2006-10-10
  • 打赏
  • 举报
回复
有点懂了,多谢

另外还有一个问题,怎样从txt文件N行数据中截取需要的一段当作源数据文件
happy_sea 2006-10-10
  • 打赏
  • 举报
回复
dim s1 as string,s2 as string
open "c:\input.txt" for input as #1
open "c:\output.csv" for output as #2
do while not eof(1)
line input #1,s1
s2=replace(s1," ",",")
print #2,s2
loop
close #1
close #2
msgbox "完工!"
吾非大神 2006-10-10
  • 打赏
  • 举报
回复
学习

7,789

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧