Beispiel #1
0
def process_upload(doc):
    file_path = filehandler.open_doc(doc)
    file_size = os.stat(file_path).st_size # because browser might not have sent content_length
    logger.debug("Upload: %d bytes", file_size)
    words = filehandler.convert_to_txt(file_path)
    filehandler.delete_file(file_path)
    return words
def process_upload(doc):
    file_path = filehandler.open_doc(doc)
    file_size = os.stat(file_path).st_size # because browser might not have sent content_length
    logger.debug("Upload: %d bytes", file_size)
    words = filehandler.convert_to_txt(file_path)
    filehandler.delete_file(file_path)
    return words
Beispiel #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
Beispiel #4
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
Beispiel #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
Beispiel #6
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