Skip to content

Importing data from excel files

Stoyfan edited this page Oct 5, 2019 · 3 revisions

How to import data from excel files

Some notes about the excel files

Compatability

This program will only import files with the file extension: .xlsx . This is achieved by using the openpyxl library. The class responsible for excel file importing is called DataFromFile.

How to import the file

You use the get_data method from the DataFromFile class to get the data which is held in a multidimetional dictionary organised by variable marker and type. (e.g data['y']['ERROR'] would return the error bar values for the y variable).

When you run the program, it will ask you to input the filename (without the file extension). If you do not follow the rules and structure below then the program will crash so be warned.

Rules and Structure that the excel file must follow

Rules

Each excel file must follow these rules, otherwise the program will crash:

  • The 'table' must start from cell A0
  • Each variable has its own cell.
  • Error bar values and data values have to be in seperate columns.
  • The columns do not need to be in a specific order.
  • Each column must have the same amount cells.
  • It must follow a defined structure.

Structure

Each column must have this structure:

  1. Variable marker (if it is a y variable then its just "y", otherwise it is xn where n is an integer)
  2. Type (This is either "DATA" or "ERROR").
  3. Name (Name of variable)
  4. Unit (Units of variable)
  5. Data (Which will be in cells below row 4)