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

7 Years
Discussion Span
Last Post by Ancient Dragon

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.

Edited by Ancient Dragon: n/a


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.

Votes + Comments
I knew that, I was just testing you :)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.