View previous topic :: View next topic |
Author |
Message |
lal Beginner
Joined: 21 Oct 2003 Posts: 70 Topics: 25
|
Posted: Wed Jan 18, 2006 10:41 am Post subject: Convert CSV file to the Text file |
|
|
Hi Friends,
I have a csv (comma separated) file which I would like to convert to .txt file so that I could this .txt file in the cobol program.
I have 2 solutions to achieve this one is by Easytrieve and other is by the cobol program. But our peers want's something else like an Excel macro. Could some-one help me in this regard ???
(I am not sure whether I could post this topic in this forum as it involves Excel macro. If yes I appologise for that)
Data format:-
TS08888,"Jones,Mary",Austin,Texas 52222
Here name i.e., Jones,Mary is to be treated as only one
Thanx,
Lal |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
Bithead Advanced

Joined: 03 Jan 2003 Posts: 550 Topics: 23 Location: Michigan, USA
|
Posted: Wed Jan 18, 2006 11:27 am Post subject: |
|
|
Here is a very simple example:
Code: |
Sub Export()
Dim RowSub As Integer
Dim ColSub As Integer
Dim FileText As String
Open "d:\temp\myfile.txt" For Output As #1
RowSub = 1 'set to 2 if there is a header
Do Until Cells(RowSub, 1).Value = ""
FileText = ""
ColSub = 1
Do Until Cells(RowSub, ColSub).Value = ""
FileText = FileText & Cells(RowSub, ColSub).Value
ColSub = ColSub + 1
Loop
Print #1, FileText
RowSub = RowSub + 1
Loop
Close #1
End Sub
|
|
|
Back to top |
|
 |
lal Beginner
Joined: 21 Oct 2003 Posts: 70 Topics: 25
|
Posted: Wed Jan 18, 2006 12:30 pm Post subject: |
|
|
Thanx Kolusu & Bithead for your replies.
Thanx,
Lal |
|
Back to top |
|
 |
SureshKumar Intermediate
Joined: 23 Jan 2003 Posts: 211 Topics: 21
|
Posted: Wed Jan 18, 2006 12:53 pm Post subject: |
|
|
lal,
Do you intend to do this on the MF or on Desktop(Excel)? Since you are referring to Excel Macro, may be in Excel. Why would you require a macro? why not save the file as .txt(TAB Delimited). Jones,Mary would be stored as "Jones,Mary ", later is " are not required you can replace all with spaces. Thanks |
|
Back to top |
|
 |
|
|