Converting text for csv

H

houghi

Where can I find information on how to correctly export a file to csv,
so I can import it in MySQL correctly?

I start with something like "Chaussée". When I export this to csv, I get
"Chauss,e". What I would need is something like "Chaussée", because
when I import that, I do get "Chaussée" back on my site.

I could replace each "é" with "é", but that letter is not the only one
and there might be letters added later that are not there now.

Is there information on what to do exacly, or a script I could download
that does this for me?
 
J

Joel

I get this with the code below : Chaussée
This is the custom code I give everybody who has problems with the Excel CSV
save function. there are lots of problems with the way excel saves CSV
files. This solution always seems to work.

Sub WriteCSV()
Const MyPath = "C:\temp\"
Const WriteFileName = "text.csv"

Const Delimiter = ","
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Set fswrite = CreateObject("Scripting.FileSystemObject")
'open files
WritePathName = MyPath + WriteFileName
fswrite.CreateTextFile WritePathName
Set fwrite = fswrite.GetFile(WritePathName)
Set tswrite = fwrite.OpenAsTextStream(ForWriting, TristateUseDefault)

LastRow = Cells(Rows.Count, "A").End(xlUp).Row

For RowCount = 1 To LastRow
LastCol = Cells(RowCount, Columns.Count).End(xlToLeft).Column
For ColCount = 1 To LastCol
If ColCount = 1 Then
OutputLine = "," & Cells(RowCount, ColCount)
Else
OutputLine = OutputLine & Delimiter & Cells(RowCount, ColCount)
End If
Next ColCount
OutputLine = OutputLine & ","
tswrite.writeline OutputLine
Next RowCount

tswrite.Close

End Sub
 
H

houghi

Joel said:
I get this with the code below : Chaussée
This is the custom code I give everybody who has problems with the Excel CSV
save function. there are lots of problems with the way excel saves CSV
files. This solution always seems to work.

Thanks. I will try it on Monday when I am back at the office and have
Excel available.

houghi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top