Python import table data from Mac .numbers file

17,349

Solution 1

Numpy is a great library for importing data.

For example:

import numpy as np
import
ran = np.array([(np.loadtxt"a.txt"), delimiter =';'])
print(ran[1])

And you can then manipulate your data as arrays as shown here: https://s3.amazonaws.com/assets.datacamp.com/blog_assets/Numpy_Python_Cheat_Sheet.pdf

Solution 2

The numbers-parser library can be used to parse .numbers files. From the example on the Github page:

from numbers_parser import Document
doc = Document("my-spreasdsheet.numbers")
sheets = doc.sheets()
tables = sheets[0].tables()
rows = tables[0].rows()
Share:
17,349
pappusenpai
Author by

pappusenpai

Updated on June 16, 2022

Comments

  • pappusenpai
    pappusenpai about 2 years

    I'm new to Python and I'm trying to crunch some numbers. Sample attached: Open High Low Close Sample Data

    I have tested a few variations of importing data but failed. Really appreciate some advise. Thanks!

    path = 'Data/Price.numbers'
    with open(path) as file:    
    file.readline()
    for line in file:
        values = map(float, line.split())
        test.append(values)
    

    Key Objectives:

    1) Efficiently store the table data in a format that I can easily manipulate and apply calculations > I'm thinking of a Dict{} > Any comments?

    2) Optimised for quick calculations as I need to crunch data for multiple securities > I estimate about 1,000,000 to 2,000,000 datapoint.

    Again, appreciate any advise to do this better.