Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Batch converting CSV files from comma-decimal to period-decimal


I have a monstruous amount of data, in several folders and subfolders,
stored in CSV format. Unfortunately, these CSVs are in ISO standard for
punctuation:

. for separating three digits
, to separate the integer and the fraction
; to separate between values

I need to transform all of them to the american standard

no separation between three digits
. to separate the integer and the fraction
, to separate between values

I cannot reconfigure the international config on the computer which
will read the data, it needs to be in the american standard to run
matlab's interface with excel.

So far, i have been handling this by opening the individual CSVs in
word and substituting the relevant chars with macros, then saving and
going back to excel :( Im in a desperate need of a more efficient
manner to batch convert all CSVs to american standard.


--
Nodles
------------------------------------------------------------------------
Nodles's Profile: http://www.excelforum.com/member.php...o&userid=29391
View this thread: http://www.excelforum.com/showthread...hreadid=558251

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Batch converting CSV files from comma-decimal to period-decimal


Try the following VBA

Const SourceFilePath = "C:\tempsource\"
Const TargetFilePath = "C:\temptarget\"


Sub Convert()
Close
Filename = Dir(SourceFilePath & "*.csv")
Do While SourceFilePath < ""
Open SourceFilePath & Filename For Input As #1
Open TargetFilePath & Filename For Output As #2
Do While Not EOF(1)
Line Input #1, FileLine
FileLine = Application.Substitute(FileLine, ".", "") 'changes .
to nothing
FileLine = Application.Substitute(FileLine, ",", ".") 'changes
, to .
FileLine = Application.Substitute(FileLine, ";", ",") 'changes
; to ;
Print #2, FileLine
Loop
Close #1
Close #2
Filename = Dir()
Loop
End Sub

You need to create the tempsource and temptarget directories. Copy the
files into the tempsource folder and the macro will populate the
temptarget folder with the modified files.

Good luck!


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=558251

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Batch converting CSV files from comma-decimal to period-decimal


Works very well mrice thx :) However, this code does not seem to scan
subfolders for files.

I would need to scan all folders and subfolders in SourceFilePath and
rebuild the folder structure in TargetFilePath. Can this be done in
VBA?


--
Nodles
------------------------------------------------------------------------
Nodles's Profile: http://www.excelforum.com/member.php...o&userid=29391
View this thread: http://www.excelforum.com/showthread...hreadid=558251

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Batch converting CSV files from comma-decimal to period-decimal


You might find something close to what you need on the third tab on the
workbook on my download page. The macro uses recursion to delve into
the sub folder structure


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=558251

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
batch import dat files The Real Jd Excel Discussion (Misc queries) 2 February 16th 05 12:35 PM
Cannot access read-only documents. tomgillane Excel Discussion (Misc queries) 14 February 7th 05 10:53 PM
Converting numbers to date format from csv files FiBee Excel Discussion (Misc queries) 1 January 12th 05 01:30 PM
Stop Excel from converting text labels in CSV files to Values Just Want a Label! Excel Discussion (Misc queries) 1 January 11th 05 04:51 PM
converting lotus 123 files to excel Pete New Users to Excel 6 January 3rd 05 07:25 PM


All times are GMT +1. The time now is 04:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"