Home > other >  Writing table data using XLWT loop program error Traceback (the most recent call last) :
Writing table data using XLWT loop program error Traceback (the most recent call last) :

Time:10-03

The code
The import XLWT
Workbook=XLWT. Workbook ()
Worksheet=workbook. Add_sheet (' sheet1)
Data=https://bbs.csdn.net/topics/np.arange (1, 65). Reshape (8, 8)
For r in the range (8) :
For c in range (8) :
Worksheet. Write (r, c, data/r, c)
Workbook. Save (' F: \ data \ ex4. XLS)

An error display:
Traceback (the most recent call last) :
The File "F: pyx/01. Py", line 157, in & lt; module>
Worksheet. Write (r, c, data/r, c)
File "F: \ python \ lib \ site - packages \ XLWT \ Worksheet py", line 1088, in the write
The self. The row (r). Write (c, label, style)
File "F: \ python \ lib \ site - packages \ XLWT \ Row py", line 254, in the write
Raise the Exception (" Unexpected data type % r "% type (label))
Exception: Unexpected data type & lt; The class 'numpy. Int32 & gt;

Can't use the data (r, c) I tried to put the data (r, c) modified into 0, Run successfully

CodePudding user response:

Does not support numpy format, data. Astype (int)

CodePudding user response:

reference 1st floor shalkey response:
does not support numpy format, data. Astype (int)

That how to import the contents of the array list?

CodePudding user response:

 
Worksheet. Write (r, c, int (data (r, c)))

CodePudding user response:

refer to the second floor Running0 response:
Quote: refer to 1st floor shalkey response:
does not support numpy format, data. Astype (int)

That how to import the contents of the array list?

Converted to int casually and import, the third floor

CodePudding user response:

refer to the second floor Running0 response:
Quote: refer to 1st floor shalkey response:
does not support numpy format, data. Astype (int)

That how to import the contents of the array list?

Converted to int casually and import, the third floor

CodePudding user response:

refer to the second floor Running0 response:
Quote: refer to 1st floor shalkey response:
does not support numpy format, data. Astype (int)

That how to import the contents of the array list?

Converted to int casually and import, the third floor

CodePudding user response:

The
reference 3 floor seakingx response:
 
Worksheet. Write (r, c, int (data (r, c)))


If the inside of the array format is several kinds, such as string, number, how to import

CodePudding user response:

refer to 7th floor Running0 response:
Quote: reference seakingx reply: 3/f
 
Worksheet. Write (r, c, int (data (r, c)))


If the inside of the array format is several kinds, such as string, number, how to import

STR (data (r, c)) shall be generated string, import excel
  • Related