ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Converting text for csv (https://www.excelbanter.com/excel-discussion-misc-queries/182502-converting-text-csv.html)

houghi

Converting text for csv
 
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?

--
houghi http://www.houghi.org
My experience with SuSE Linux 9.1

The businessworld is like prison and M$ made everybody their bitch.


joel

Converting text for csv
 
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
"houghi" wrote:

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?

--
houghi http://www.houghi.org
My experience with SuSE Linux 9.1

The businessworld is like prison and M$ made everybody their bitch.



houghi

Converting text for csv
 
Joel wrote:
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
--



This space left blank intentionaly


All times are GMT +1. The time now is 06:17 AM.

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