Bob
Bob

Reputation: 453

Split Excel worksheet using Python

I have excel files (hundreds of them) that look like this (sensor output):

Column1          Column2    Column3

Serial Number:
10004
Ref. Temp:
25C
Ref. Pressure:
1KPa
Time              Temp.     Pres.
1                 21        1
2                 22        1.1
3                 23        1.2
.                 .         .
.                 .         .
.                 .         .

I want to split this into two parts, the information section (top part) and data section (the rest), something like this:

Information section

Column1          Column2    Column3

Serial Number:
10004
Ref. Temp:
25C
Ref. Pressure:
1KPa

Data section:

Column1      Column2    Column3
Time          Temp.     Pres.
1              21       1
2              22       1.1
3              23       1.2
.              .            .
.              .            .
.              .            .

if it converts to data frame I don't want the first row and column become header and index of the data frame. I am using python 2.7 and numpy.

Upvotes: 0

Views: 194

Answers (1)

Vityata
Vityata

Reputation: 43585

  • Make two copies of the worksheet.
  • In copy A, start a loop, going on the first column looking for the word Time. Once it finds it, let it delete anything before it.
  • Remember the row in a variable.
  • In copy B, delete anything after the remembered row to row number 2^20.

Upvotes: 1

Related Questions