Excel 변환 파일을 탭 제한 txt 파일 (캐리지 리턴이없는 파일)로 변환하려고합니다. 현재 나는 대량 엑셀 파일을 .txt 파일로 변환하는 스크립트 (이 포럼에서 발견됨)를 사용하고 있습니다.excel 파일을 txt 파일로 변환 (캐리지 리턴이없는 경우)
스크립트는
' @file: xl2tab.vbs
' @author: stephen brown - [email protected]
' @date: 2009-Dec-10
'
' @description: mass convert excel files to tab-delimited files
'
' @usage: place in top-level directory where excel files are contained and double-click.
' script will recursively access all subdirectories and convert each excel file to
' tab delimited file. All output will be in "output" folder, which retains structure
' of original directories
Dim saveDirBase
set fso = CreateObject("Scripting.FileSystemObject")
set shell = CreateObject("WScript.Shell")
set objExcel = CreateObject("Excel.Application")
set top = fso.GetFolder(shell.CurrentDirectory)
saveDirBase = top & "\" & "output"
Sub TraverseFolders(path)
set folder = fso.GetFolder(path)
XL2Tab(folder)
For each item in folder.SubFolders
If item.Path <> saveDirBase Then
Call TraverseFolders(item.Path)
End If
Next
set folder = Nothing
End Sub
Sub XL2Tab(folder)
Dim saveDir
set files = folder.Files
If folder.Name <> top.Name Then
saveDir = saveDirBase & "\" & folder.Name
Else
saveDir = saveDirBase
End If
If fso.FolderExists(saveDir) = False Then
fso.CreateFolder(saveDir)
End If
For each file In files
If file.Name <> Wscript.ScriptName Then
objExcel.Application.DisplayAlerts = False
Set objWorkbook = objExcel.Workbooks.open(folder.Path & "\" & file.Name)
objWorkbook.SaveAs saveDir & "\" & file.Name & ".txt", -4158
objWorkbook.close
objExcel.Application.DisplayAlerts = True
End If
Next
End Sub
If fso.FolderExists(saveDirBase) = False Then
fso.CreateFolder(saveDirBase)
End If
Call TraverseFolders(top)
내가 모든 파일을 Excel에서 캐리지 리턴을 제거하려면 변환하기 전에이다.
나를 안내 해주세요 ...!
왜 캐리지 리턴을 제거 하시겠습니까? 모든 행을 한 행에 결합하고 싶습니까? 아니면 리눅스에서 사용하기 위해 파일을 내보내려고하십니까? –
.txt 파일을 MySQL 데이터베이스에 업로드하려고합니다. 캐리지 리턴이 포함되어 있으면 파일을 Database에로드하지 않습니다. 참고 Excel 파일은 수동으로 입력되며 일부 셀 값에는 캐리지 리턴이 있습니다. – CarlJohn
데이터를 가져 오는 방법에 문제가있을 수 있습니다. MySQL은 텍스트 데이터에서 캐리지 리턴과 관련된 문제가 없습니다. 반면에 캐리지 리턴과 텍스트를 연결하여 SQL 문을 작성하려고하면 결과 문이 올바르지 않습니다. 이것은 sql injection 공격과 비슷합니다.이 공격은 텍스트 데이터의 잘못된 문자로 인해 임의의 명령문이 실행됩니다. 언어에 따라 매개 변수화 된 쿼리를 사용하여 텍스트 데이터를 단순한 데이터로 전달할 수 있습니다. 도구를 사용하는 경우 원시 데이터 –