Last active
December 10, 2015 22:29
-
-
Save nigelbabu/4502515 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# run with messytables 0.3.0 and 0.4.0, does not work in 0.4.0 | |
import messytables as ms | |
def main(): | |
with open('testdata/xls/simple.xls') as f: | |
table_set = ms.excel.XLSTableSet.from_fileobj(f) | |
row_set = table_set.tables[0] | |
types = ms.types.type_guess(row_set.sample) | |
print types | |
if __name__ == '__main__': | |
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# In both 0.3.0 and 0.4.0, types prints what is a DateTime field as String. guess_types gets the field right for a CSV file though. | |
import messytables as ms | |
def main(): | |
with open('testdata/xls/simple.xls') as f: | |
table_set = ms.excel.XLSTableSet.from_fileobj(f) | |
row_set = table_set.tables[0] | |
guess_types = [ms.types.StringType, ms.types.IntegerType, ms.types.FloatType, ms.types.DecimalType, ms.types.DateUtilType] | |
types = ms.types.type_guess(row_set.sample) | |
print types | |
if __name__ == '__main__': | |
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import messytables as ms | |
def main(): | |
with open('testdata/csv/simple.csv') as f: | |
table_set = ms.commas.CSVTableSet.from_fileobj(f) | |
row_set = table_set.tables[0] | |
guess_types = [ms.types.StringType, ms.types.IntegerType, ms.types.FloatType, ms.types.DecimalType, ms.types.DateUtilType] | |
types = ms.types.type_guess(row_set.sample, guess_types) | |
print types | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment