Ask Your Question

GingerAndy's profile - activity

2016-07-05 16:45:34 +0100 received badge  Popular Question (source)
2016-07-05 16:45:34 +0100 received badge  Notable Question (source)
2016-07-05 16:45:34 +0100 received badge  Famous Question (source)
2013-05-20 12:57:43 +0100 answered a question import csv file: integers appearing as floating points

Thanks that works a treat.

2013-05-20 10:17:16 +0100 asked a question import csv file: integers appearing as floating points

Hi,

I am trying to import a csv file in order to create an adjacency matrix and then plot the associated directed graph. I upload the csv file and use its content to generate a matrix as follows

sage: import csv                           
sage: data = list(csv.reader(file(DATA+'matrix23.csv')))
sage: m = matrix([[ float(_) for _ in line] for line in data])
sage: m

Whereas my csv file only contains integers 1's and 0's, the generated matrix is floating point 1.0's and 0.0's!

Note: the CSV file was created using MS Excel with cells formated to zero decimal places. I'm new to both python and sage and can't find anything on the forums to help