Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python import table data from Mac .numbers file

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.

like image 469
pappusenpai Avatar asked Dec 29 '17 14:12

pappusenpai


1 Answers

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()
like image 184
Kyle Avatar answered Oct 09 '22 13:10

Kyle