statadict’s API documentation¶
Link: https://github.com/atudomain/statadict
statadict.parse_stata_dict¶
-
statadict.
parse_stata_dict
(file: str) → statadict.base.StataDict¶ Parses Stata dictionary file and returns object containing column data as attributes.
‘names’, ‘colspecs’ and ‘widths’ attributes can be used with ‘pandas.read_fwf()’.
- Parameters
file – Stata dictionary file (usually .dct extension)
- Type
str
- Returns
Object with column data as attributes
- Return type
statadict.base.StataDict¶
-
class
statadict.base.
StataDict
(column_numbers: List[int], types: List[str], names: List[str], formats: List[str], comments: List[str])¶ Class representing Stata dictionary file.
Consists of several attributes describing columns in a fixed width field csv file.
‘names’, ‘colspecs’ and ‘widths’ attributes can be used with ‘pandas.read_fwf()’.
-
property
colspecs
¶ This attribute can be used with pandas.read_fwf() as colspecs argument.
- Returns
Tuple with start and end of data for each column
- Return type
List[tuple]
-
property
column_numbers
¶ - Returns
Number for each column where that column data should start in fwf file (1-indexed)
- Return type
List[int]
-
property
comments
¶ - Returns
Optional comment for each column
- Return type
List[str]
-
property
formats
¶ - Returns
Parsing format for each column
- Return type
List[str]
-
property
names
¶ This attribute can be used with pandas.read_fwf() as names argument.
- Returns
Name for each column
- Return type
List[str]
-
property
types
¶ - Returns
Data type for each column
- Return type
List[str]
-
property
widths
¶ This attribute can be used with pandas.read_fwf() as widths argument.
- Returns
Width for each column
- Return type
List[int]
-
property