Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing case in text file to Uppercase 1

Status
Not open for further replies.

icodian

IS-IT--Management
Aug 28, 2001
74
0
0
US
I have a comma-delimited text file (.csv). I need to open the file and convert all alphanumeric characters to uppercase.

Does anyone have any suggestions?

Thanks!
 
'''Open the file you want to change asume'c:\Data.dat'
'''BEFORE RUNNING SAVE A COPY OF YOUR DATA FILE IN A SAFE SPOT - JUST INCASE

Open "c:\data.dat" FOR INPUT AS #1
OPEN "C:\TEMP.DAT" FOR OUTPUT AS #2
while not eof(1)
Line Input #1, d$
d$ = ucase(d$)
''' Move Ucase data to Temp.dat
print #2, d$
wend
close #1
close #2

''' Delete current Date.dat file
kill "C:\Data.dat
''' rename temp.dat data.dat
rename "C:\temp.dat", "C:\data.dat"
 
Do you mean that you wish to change the contents of the file to contain only uppercase? If so, my (very high level) suggestion is:

First, rename the original file
Rename <origName> to <backupName>
Open the text file:
Open <backupName>For Input As #1
Read the contents into a string variable
<string> = Input$(LOF(1), #1)
Upshift the variable
<string> = ucase(<string>)
Close the backup file
Close #1
create a new file with original name
Open <origName> For Output As #1
write the variable to the new file
Print #1, <string>
close the new file
Close #1
optionally delete the old file
Kill <backupName>

I hope that's of some help...

Phil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top