>>> Background I am learning to use sage and to integrate it into LaTeX, primarily to create problems with answers already completed. I am at the same time very much interested in creating problem statements that draw (randomly) on "databases" of values. For example, a template problem statement might be ...
############ The density of %metal% with a crystal structure %structure% is %density %. Determine its lattice parameter. ########### ... and this problem would draw values for terms in %% from a csv data base to the effect ... ########### metal, structure, density Fe, BCC, 7.87 Au, FCC, ... ... ########### ... where %metal% would for example be drawn from row 1, column 1 (offset from header) of the database. It seems I face a few issues to make this work successfully. One of them is noted here. >>> Issue I would like to have a straight-forward method of importing a csv file into a sage session, be it a notebook() instance or a \sageblock{...} region in a LaTeX file. Back in February, Marshall Hampton posted in response to a query about reading a csv file. **************** I am tempted to open a ticket in trac for some sort of read_csv command, which might behave like the following (NOTE: this is just wishful thinking at this point): data_list = read_csv('my_file.csv') # data_list would be a list of lists of row data, converted to numerical types if possible data_list = read_csv('my_file.csv', seperator = '\t') #split lines by a tab character instead data_list = read_csv('my_file.csv', fields = [int,int,string]) #perhaps useful to have more explicit field conversions **************** Basically, I am asking, does such a simple dataarray = read_csv(..) type command/function (with formatting codes) now exist somewhere? Best would be when such a csv file reader would load the data file, taking the first line in the file as the header to "tag" the column entries. To access items by tag from the first database row in SageTeX, the template above might then become ... ############ The density of \sage{db.metal[1]} with a crystal structure \sage {db.structure[1]} is \sage{db.density[1]}. Determine its lattice parameter. ########### I must add that, references to this, that, or the other python/sage command that I can use to "roll my own" basic csv file importer might all be wonderful but will be more of a frustration for me at this stage. Thanks! -- JJW --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---