我需要一个脚本来为我的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经验。
谢谢你, 添
答案 0 :(得分: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