0

我需要一个脚本来为 csv 文件中的每一行创建一个空文本文件。

我的 csv 文件有 3 列数据...

Along Came Polly,2003,192
American Beauty,1999,146
American Cousins,2007,286
An American Crime,2007,179

我想为每一行创建一个空文本文件,并格式化为....

Along Came Polly (2003) Slot 192.txt
American Beauty (1999) Slot 146.txt
American Cousins (2007) Slot 286.txt
An American Crime (2007) Slot 179.txt

有人可以帮我解决这个问题,因为我没有 vb 经验。

谢谢你,蒂姆

4

1 回答 1

0

这就是您可能正在寻找的

Option Explicit
Dim objFSO, objTextFile, strFileLine,objFile,strFileName



' Create the File System Object
 Set objFSO = CreateObject("Scripting.FileSystemObject")


 Set objTextFile=objFSO.OpenTextFile("C:\Documents and Settings\amolc\Desktop\SO\Sample.csv")  ''Mention Path of your CSV file here 


 Do Until objTextFile.atEndOfStream
     strFileLine =objTextFile.ReadLine
     strFileLine =Split(strFileLine,",")
     strFileName=strFileLine(0)&" ("&strFileLine(1)&") "&"Slot "&strFileLine(2)&".txt"
     Set objFile = objFSO.CreateTextFile("C:\Documents and Settings\amolc\Desktop\SO\"&strFileName)  ''Hardcoded path is the location where you can store your text file
Loop
于 2012-07-20T04:40:47.797 回答