Ejemplo n.º 1
0
    def test_that_importing_a_csv_and_an_excel_file_with_identical_data_produce_an_identical_spreadsheet_object(self):
        csv_filename = "nameemail.csv"
        excel_filename = "nameemail.xls"
        
        fh1 = open(os.path.join(settings.PROJECT_ROOT, TEST_SPREADSHEET_PATH, csv_filename ), 'r')
        s = SpreadsheetAbstraction(self.a1, fh1, "people", filename=csv_filename)
        csv_data = s.get_rows(0,s.num_rows)
        fh1.close()

        fh2 = open(os.path.join(settings.PROJECT_ROOT, TEST_SPREADSHEET_PATH, excel_filename ), 'r')
        s = SpreadsheetAbstraction(self.a1, fh2, "people", filename=excel_filename)
        excel_data = s.get_rows(0,s.num_rows)
        fh2.close()

        self.assertEqual(csv_data, excel_data)
Ejemplo n.º 2
0
    def upload_complete(self, request, filename, **kwargs):
        self._pool.close()
        self._pool.join()
        self._mp.complete_upload()


        # filename is a file at s3.  Get it.
        f = default_storage.open(filename, 'r')

        # parse the file.
        s = SpreadsheetAbstraction(request.account, f, request.import_type, filename=filename)
        f.close()
        
        # get the number of rows
        num_rows = s.num_rows

        # see if it has a header
        header_row = []
        has_header = s.has_header
        if s.has_header:
            header_row = s.header_row
        
        # get the first five columns
        first_rows = s.get_rows(0,8)

        return_dict = {
            'num_rows': num_rows,
            'first_rows': first_rows,
            'header_row': header_row,
            'has_header': has_header,
            'filename':filename,
        }

        return return_dict