How to Convert CSV file to Excel File

149 views
Skip to first unread message

nagesh

unread,
Sep 27, 2010, 11:06:11 AM9/27/10
to QTP - HP Quick Test Professional - Automated Software Testing
Hi,

I have a CSV file which is downloaded from UI , i need to compare the
values with DB values whether to check the content is correct or not

and also my CSV file doesnot have any Delimiter, here i have attached
my CSV file please help me on this
i have tried to convert but it is preserving the Zeros

Thanks,
Venkata

venkat ch12

unread,
Sep 27, 2010, 11:08:07 AM9/27/10
to QTP - HP Quick Test Professional - Automated Software Testing
Here i have attahced CSV file and Excel file which i have converted
data_export.csv
data_export.xls

Ganesh muralidharan

unread,
Sep 27, 2010, 1:04:02 PM9/27/10
to mercu...@googlegroups.com
I could not get the issue after going through the .csv and .xls maybe
with excel 2007 the .csv opens properly. Not sure.

Anyways pasting a previous function pasted to convert .csv to .xls

Function ConvertCSVFiletoXLSFile(sSrcFile, sDestFile)
Const xlWorkbookNormal = -4143
Set oExcel = CreateObject("Excel.Application")
oExcel.DisplayAlerts = False
oExcel.Workbooks.Open(sSrcFile)
oExcel.ActiveWorkbook.SaveAs sDestFile,xlWorkbookNormal
oExcel.Workbooks.Close()
set oExcel =Nothing
End Function

ConvertCSVFiletoXLSFile "C:\sampls.csv", "C:\sample.xls"

> --
> You received this message because you are subscribed to the Google
> "QTP - HP Quick Test Professional - Automated Software Testing"
> group.
> To post to this group, send email to Mercu...@googlegroups.com
> To unsubscribe from this group, send email to
> MercuryQTP+...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/MercuryQTP?hl=en

--
Regards,


Ganesh Muralidharan
'God Never Forgets'

darrell

unread,
Sep 27, 2010, 9:13:44 PM9/27/10
to QTP - HP Quick Test Professional - Automated Software Testing
You have to define "correct content" in order to compare two files. If
the order of the rows are important it would be a simple compare. If
the order of the rows is not important then I would sort the rows then
compare the files.

Comparing the files would then be a simple, external application. If
you are just looking for a pass/fail then use an application which
returns -1, 0 and 1. If the return value is 0 they are the same
(pass). Otherwise they are different (fail).

There is no CSV file attached to this message. If the data_export.csv
attached to the next message is your file then 1) the file is a TSV
(tab separated values) file not a CSV (comma separated values) and 2)
it is delimited by tabs.

Darrell

venkat ch12

unread,
Sep 28, 2010, 12:14:29 AM9/28/10
to mercu...@googlegroups.com
if i am using this function when i am converting to excel it is removing the Leading Zeros can you check this in the excel "Sold to " column

S R I D H A R

unread,
Sep 28, 2010, 12:47:50 AM9/28/10
to mercu...@googlegroups.com


Thanks
SRIDIVYADHAR

Ganesh muralidharan

unread,
Sep 28, 2010, 8:21:34 AM9/28/10
to mercu...@googlegroups.com
Is your requirement solved? You didnot want to preserve the zeros right?

--

venkat ch12

unread,
Sep 29, 2010, 1:41:49 AM9/29/10
to mercu...@googlegroups.com
yes i dont want to preserve zeros it should convert with zeros
Reply all
Reply to author
Forward
0 new messages