ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   txt tab-delimited to CSV (https://www.excelbanter.com/excel-programming/384712-txt-tab-delimited-csv.html)

[email protected]

txt tab-delimited to CSV
 

We use a program which is only able to export data into 'tab-
delimited' text files. We need data from this program to go to
another which can only read CSV files.

Is there a way to script this so it automatically converts the
contents of a text file to a csv which can be opened in excel?

Thanks


Jean-Yves[_2_]

txt tab-delimited to CSV
 
Hi,
XL is also able to open tab delimited files, but you have to open them via
XL.
What file format do you want to convert ?
Regards
JY
wrote in message
oups.com...

We use a program which is only able to export data into 'tab-
delimited' text files. We need data from this program to go to
another which can only read CSV files.

Is there a way to script this so it automatically converts the
contents of a text file to a csv which can be opened in excel?

Thanks




[email protected]

txt tab-delimited to CSV
 
On 7 Mar, 11:36, "Jean-Yves" wrote:
Hi,
XL is also able to open tab delimited files, but you have to open them via
XL.
What file format do you want to convert ?
Regards
wrote in message

oups.com...





We use a program which is only able to export data into 'tab-
delimited' text files. We need data from this program to go to
another which can only read CSV files.


Is there a way to script this so it automatically converts the
contents of a text file to a csv which can be opened in excel?


Thanks- Hide quoted text -


- Show quoted text -


Thanks for replying.

Yes, i am aware XL can open tab-delimited but we need the process
automated so no user intervention is required.


Jean-Yves[_2_]

txt tab-delimited to CSV
 
ok, But what is the file format, eg .txt ?
JY
wrote in message
ps.com...
On 7 Mar, 11:36, "Jean-Yves" wrote:
Hi,
XL is also able to open tab delimited files, but you have to open them
via
XL.
What file format do you want to convert ?
Regards
wrote in message

oups.com...





We use a program which is only able to export data into 'tab-
delimited' text files. We need data from this program to go to
another which can only read CSV files.


Is there a way to script this so it automatically converts the
contents of a text file to a csv which can be opened in excel?


Thanks- Hide quoted text -


- Show quoted text -


Thanks for replying.

Yes, i am aware XL can open tab-delimited but we need the process
automated so no user intervention is required.




[email protected]

txt tab-delimited to CSV
 
On 7 Mar, 11:55, "Jean-Yves" wrote:
ok, But what is the file format, eg .txt ?
wrote in message

ps.com...



On 7 Mar, 11:36, "Jean-Yves" wrote:
Hi,
XL is also able to open tab delimited files, but you have to open them
via
XL.
What file format do you want to convert ?
Regards
wrote in message


groups.com...


We use a program which is only able to export data into 'tab-
delimited' text files. We need data from this program to go to
another which can only read CSV files.


Is there a way to script this so it automatically converts the
contents of a text file to a csv which can be opened in excel?


Thanks- Hide quoted text -


- Show quoted text -


Thanks for replying.


Yes, i am aware XL can open tab-delimited but we need the process
automated so no user intervention is required.- Hide quoted text -


- Show quoted text -


sorry, the tab-delimited is in text (txt) format.. and it is required
to be in CSV format.
:)


Kana

txt tab-delimited to CSV
 

wrote:
We use a program which is only able to export data into 'tab-
delimited' text files. We need data from this program to go to
another which can only read CSV files.

Is there a way to script this so it automatically converts the
contents of a text file to a csv which can be opened in excel?

Thanks


I got the answer on another topic now.

Thanks anyways


Dave Peterson

txt tab-delimited to CSV
 
Maybe something like this:

Option Explicit
Sub testme01()

Dim myFileNames As Variant
Dim myArray() As Variant
Dim iCtr As Long
Dim maxFields As Long
Dim wkbk As Workbook
Dim NewFileName As String

maxFields = Worksheets(1).Columns.Count

myFileNames = Application.GetOpenFilename _
(filefilter:="Text Files, *.txt", MultiSelect:=True)

If IsArray(myFileNames) = False Then
Exit Sub 'user hit cancel
End If

ReDim myArray(1 To maxFields, 1 To 2)
For iCtr = 1 To maxFields
myArray(iCtr, 1) = iCtr
'bring it in as text--so nothing changes
myArray(iCtr, 2) = xlTextFormat
Next iCtr

For iCtr = LBound(myFileNames) To UBound(myFileNames)
Workbooks.OpenText Filename:=myFileNames(iCtr), _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, _
FieldInfo:=myArray

If LCase(Right(myFileNames(iCtr), 4)) = ".txt" Then
NewFileName = Left(myFileNames(iCtr), Len(myFileNames(iCtr)) - 4)
End If
NewFileName = NewFileName & ".csv"

Set wkbk = ActiveWorkbook

'overwrite any existing .csv file
Application.DisplayAlerts = False
wkbk.SaveAs Filename:=NewFileName, FileFormat:=xlCSV
Application.DisplayAlerts = True

wkbk.Close savechanges:=False

Next iCtr

End Sub

wrote:

We use a program which is only able to export data into 'tab-
delimited' text files. We need data from this program to go to
another which can only read CSV files.

Is there a way to script this so it automatically converts the
contents of a text file to a csv which can be opened in excel?

Thanks


--

Dave Peterson


All times are GMT +1. The time now is 11:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com