hi every one i want to ask is there any way through which i can retrieve column number of csv file using c programming. those number which are by default set in cvs file also the row name i-e A B C.............. Z AA AB AC........... thanks in advance

Recommended Answers

All 3 Replies

You mean how to convert column A to column 1? Yes, that can be easily done. The quickest way would be to take the single-letter column value and subtract 'A'. So if the column name is 'C', then it would be 'C' - 'A' + 1, which is 67 - 67 + 1 = 3 (see any ascii table). If you have two-digit column name such as AA then you have to do the substraction for each of the individual letters. So that 'AC' becomes (('A' - 'A' + 1) * 10) + ('C' - 'A' + 1) which is 10 + 3 = 13

Now put all that in a loop and you can do it for any number of columns with any number of digits in the column name.

So that 'AC' becomes (('A' - 'A' + 1) * 10) + ('C' - 'A' + 1) which is 10 + 3 = 13

Except that AC is actually 29 (after Z comes AA, AB, AC, etc.), so for AA to be 27, A has to be 1 (you'd have to shift everything down by 1 to get a zero based index).

One way to make your life a little easier is to turn on the "R1C1 reference style" (I have it under Excel Options/Formulas/Working with Formulas in Excel 2007. This will give you a (1-based) column designation for each cell.

commented: I knew that, I was just testing you :) +36

>>Except that AC is actually 29 (after Z comes AA, AB, AC, etc.), so for AA to be 27,
Oh yes -- of course, duuuuh!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.