예제 #1
0
 def test_import_xls(self):
     test_data_path = os.path.join(self._fixtures_dir,
                                   'zachary-karate-club.xlsx')
     csv_file = filehandler.convert_to_csv(test_data_path)[0]
     results = ctd.get_summary(csv_file)
     self.assertEqual(results['nodes'], 34)
     self.assertEqual(results['edges'], 78)
예제 #2
0
파일: wtfcsv.py 프로젝트: c4fcm/DataBasic
def process_upload(csv_file):
    file_path = filehandler.open_doc(csv_file)
    file_size = os.stat(file_path).st_size # because browser might not have sent content_length
    logger.debug("Upload: %d bytes", file_size)
    file_paths = filehandler.convert_to_csv(file_path)
    results = []
    for f in file_paths:
        summary = wtfcsvstat.get_summary(f)
        if 'bad_formatting' not in summary:
            summary['sheet_name'] = _get_sheet_name(f)
            summary['filename'] = csv_file.filename
        results.append(summary)
    filehandler.delete_files(file_paths)
    return results
예제 #3
0
def process_upload(csv_file):
    file_path = filehandler.open_doc(csv_file)
    file_size = os.stat(
        file_path
    ).st_size  # because browser might not have sent content_length
    logger.debug("Upload: %d bytes", file_size)
    file_paths = filehandler.convert_to_csv(file_path)
    results = []
    for f in file_paths:
        summary = wtfcsvstat.get_summary(f)
        if 'bad_formatting' not in summary:
            summary['sheet_name'] = _get_sheet_name(f)
            summary['filename'] = csv_file.filename
        results.append(summary)
    filehandler.delete_files(file_paths)
    return results
예제 #4
0
def process_upload(file, has_header_row=True):
    """
    Return results for an uploaded file
    """
    file_path = filehandler.open_doc(file)
    file_name = file.filename
    file_size = os.stat(file_path).st_size
    logger.debug('[CTD] File size: %d bytes', file_size)

    csv_paths = filehandler.convert_to_csv(file_path)
    results = ctd.get_summary(csv_paths[0], has_header_row) # only use first sheet
    results['has_multiple_sheets'] = True if len(csv_paths) > 1 else False
    results['filename'] = file_name

    filehandler.delete_files(csv_paths)
    return results
예제 #5
0
def process_upload(file, has_header_row=True):
    """
    Return results for an uploaded file
    """
    file_path = filehandler.open_doc(file)
    file_name = file.filename
    file_size = os.stat(file_path).st_size
    logger.debug('[CTD] File size: %d bytes', file_size)

    csv_paths = filehandler.convert_to_csv(file_path)
    results = ctd.get_summary(csv_paths[0],
                              has_header_row)  # only use first sheet
    results['has_multiple_sheets'] = True if len(csv_paths) > 1 else False
    results['filename'] = file_name

    filehandler.delete_files(csv_paths)
    return results
예제 #6
0
 def test_convert_to_csv(self):
     fixture_path = os.path.join(self._fixtures_dir,'HowAmericaInjuresItself_FromNEISS.xlsx')
     results = filehandler.convert_to_csv(fixture_path)
     self.assertEqual(len(results),1)
예제 #7
0
 def test_get_summary_from_xls(self):
 	fixture_path = os.path.join(self._fixtures_dir,'HowAmericaInjuresItself_FromNEISS.xlsx')
     csv_file = filehandler.convert_to_csv(fixture_path)[0]
     results = wtfcsvstat.get_summary(csv_file)
     self.assertEqual(len(results['columns']), 19)
     self.assertEqual(results['row_count'], 26303)
예제 #8
0
 def test_import_xls(self):
     test_data_path = os.path.join(self._fixtures_dir, "zachary-karate-club.xlsx")
     csv_file = filehandler.convert_to_csv(test_data_path)[0]
     results = ctd.get_summary(csv_file)
     self.assertEqual(results["nodes"], 34)
     self.assertEqual(results["edges"], 78)
예제 #9
0
 def test_convert_to_csv(self):
     fixture_path = os.path.join(self._fixtures_dir,
                                 'HowAmericaInjuresItself_FromNEISS.xlsx')
     results = filehandler.convert_to_csv(fixture_path)
     self.assertEqual(len(results), 1)