csv.empty_str

View page source

Create A Table from a CSV File

Prototype

# at_cascade.csv.empty_str
def empty_str(table_in, direction) :
   assert type(table_in)  == list
   if len(table_in) > 0 :
      assert type(table_in[0]) == dict
   assert direction == 'to_none' or direction == 'from_none'
   # ...
   assert type(table_out) == list
   if len(table_out) > 0 :
         assert type(table_out[0]) == dict
   return table_out

table_in

is a list of dict. We use n to denote the length of the list which is the number of lines in the file minus one. For i, an int , between zero and n -1, and each column name key , a string, table [ i ][ key ] is the str in line i +2 and column key.

direction

is a str that is equal to to_none or from_none.

to_none

If direction is to_none, then every empty string is converted to None. In this case there cannot be any None field values in the input.

from_none

If direction is from_none, then every None value is converted to the empty string. In this case there cannot be any empty string values in the input.

table_out

Is a copy of table_in after doing the conversion.

Example

csv.table