Manipulating data in xls format from CUDA

Can anyone please tell me the way to manipulate the data of excel worksheet(in xls format) using CUDA?
I need to send the raw data from excel to GPU to perform data manipulation and then return it to cpu and save the file. Please help me out…

This has been discussed on the forum in the past. Nothing came out, though.

Are you saying that you intend to write a program that processes xls files?

Actually the data are in the tab separated format and is saved as xls format. I need to put individual datum of the xls file in an array to be transferred to GPU using cudamemcpy(). I need to manipulate these data in GPU and then transfer the data back to cpu and again save in xls format with another file name…Can you help me out plz??

Why would you guys save it in xls format when you are not going to use Excel to do the editing? Save it in some simpler format! But if this is not possible, then you’ll just have to deal with the xls format itself, which appears quite complicated to me.

I didn’t save it in xls format…the data received is saved automatically in xls format…However, i found a way to open xls file from C and then save it back again to xls…Thank you for your reply…

I believe it is as easey as doing an fopen(…) ( in C ) on your xls document and reading with the proper “\t” or “\n” to access the right cells.

If you are using C# then there are API:s which make the access much more generic and trivial.

The .xls file format is not a text file, although Excel can import both tab and comma separated text files as spreadsheets. (And delimited text files are definitely the way to go for small-scale data exchange.) The .xlsx format is a zip file containing an XML file + other attachments.

mhmm I do know that you can treat the .xls as if it was a regular .txt file.

Hi,

This is how it should be done.

Import the xls file (parser)

run the cuda job

Export a new xls file.

Importer: In this step you need to parse the xls file into a suitable format. This does not mean that you read in the file, you need to understand the data inside it.

So you will have to dig in to xls specifications, but when you understand the specification and the structure of the xls file the rest is easy. Just open the file as a binary stream and parse everything into your format.

Exporter: The same as for importer but in reverse :D

You could take a look at http://www.libxl.com/

I have not tried it myself.

??? If I hexdump the first .xls file I find on my hard drive, I get this:

00000000  d0 cf 11 e0 a1 b1 1a e1  00 00 00 00 00 00 00 00  |................|

00000010  00 00 00 00 00 00 00 00  3e 00 03 00 fe ff 09 00  |........>.......|

00000020  06 00 00 00 00 00 00 00  00 00 00 00 01 00 00 00  |................|

00000030  01 00 00 00 00 00 00 00  00 10 00 00 3d 00 00 00  |............=...|

00000040  01 00 00 00 fe ff ff ff  00 00 00 00 00 00 00 00  |................|

00000050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

[snip, snip]

There are string fragments much later in the file that look like column headings, but cell data seems pretty unintelligible. I mean, certainly if you know how BIFF is structured, you can write an input driver using fread() and all that to get the cells. But it isn’t “text” in the human readable sense for numeric data as far as I can tell.

Anyway, this is way off topic. Reading data from a file is outside the scope of CUDA, and the topic author seems to have figured out a solution already. :)

I think we might be talking about different things.

I meant doing a simple fprintf like you could to any text file for example:

FILE* file;

	file = fopen("myExcelFile.xls","w+");

	for(int i = 0; i < 5; i++)

	{

		for(int j = 0; j < 5; j++)

		{

			fprintf(file,"\t %d", j +i*5);

		}

		fprintf(file,"\n");

	}

	fclose(file);

Would give you an ouput with:

If you wanted to store data in an excel sheet using C this could be one easy way ( maybe not very effective from a performance perspective).

Sorry for spamming on this topic :P

I actually did this:

fopen_s( &streamread, “Raw Data 16.xls”, “r” )

to read the xls file and since it was in tab separated format i used this

char delims = “\t”;
result = strtok( str, delims );

and it worked pretty well…after this I have to put the values in array…

Hi,

Yes this will work, but it is not true for all cases.

Do the same thing in excel:

  1. enter all values inside cells.

  2. Save as *.xls

  3. open it in notepad.

Conclusion: If you have a *.xls file generated by Excel you will not be able to open is as you are doing and editing it the same way.

On the other hand if you generate your own *.xls file (as a text file) Excel is smart enough to notice this and give you a wizard to specify the delimiter and thus parse it correctly.

What you are looking for is the *.csv file type.

http://en.wikipedia.org/wiki/Comma-separated_values

If you want to load the *.csv file into Excel then use: Data->Import External Data -> Import Data

And the other way around: If you have data inside an Excel sheet that you want to save as plain text then use: Save (and save it as *.csv)

Then you will be able to open it in notepad and understand the text.