spinetoolbox.spine_io.importers.csv_reader
¶
Contains CSVConnector class and a help function.
author: |
|
---|---|
date: | 1.6.2019 |
Module Contents¶
-
spinetoolbox.spine_io.importers.csv_reader.
select_csv_file
(parent=None)[source]¶ Launches QFileDialog with no filter
-
class
spinetoolbox.spine_io.importers.csv_reader.
CSVConnector
[source]¶ Bases:
spinetoolbox.spine_io.io_api.SourceConnection
Template class to read data from another QThread.
-
_ENCODINGS
= ['utf-8', 'utf-16', 'utf-32', 'ascii', 'iso-8859-1', 'iso-8859-2'][source]¶ List of available text encodings
-
static
parse_options
(options)[source]¶ Parses options dict to dialect and quotechar options for csv.reader
Parameters: options (dict) – dict with options: “encoding”: file text encoding “delimiter”: file delimiter “quotechar”: file quotechar “has_header”: if first row should be treated as a header “skip”: how many rows should be skipped Returns: - tuple dialect for csv.reader,
- quotechar for csv.reader and number of rows to skip
Return type: tuple(dict, bool, integer)
-
file_iterator
(self, options, max_rows)[source]¶ creates an iterator that reads max_rows number of rows from text file
Parameters: - options (dict) – dict with options:
- max_rows (integer) – max number of rows to read, if -1 then read all rows
Returns: iterator of csv file
Return type: iterator
-
get_data_iterator
(self, table, options, max_rows=-1)[source]¶ Creates an iterator for the file in self.filename
Parameters: - table (string) – ignored, used in abstract IOWorker class
- options (dict) – dict with options
Keyword Arguments: max_rows (int) – how many rows of data to read, if -1 read all rows (default: {-1})
Returns: Return type: tuple
-