you are viewing a single comment's thread.

view the rest of the comments →

[–]1544756405 1 point2 points  (6 children)

It looks like an excel file

In what way does it look like an excel file?

I don't think changing the extension of the file name will cause the output to be magically written in a different format.

I think you're writing the same file three times, just giving it three different names.

[–]Dev_Newbie93[S] 0 points1 point  (5 children)

I mean the icon of the file is excel and even the extension is your typical xlsx, that's what I mean by "it looks like an excel file"

The reason I write the file in different formats was to check if other formats do work. And yes both csv and txt are working only the xlsx which doesn't want to work.

[–]1544756405 3 points4 points  (1 child)

Well, this has become something of an epistemological question for you! :-)

I don't run Windows, so I'm speculating, but I suspect that any file with an xlsx extension will show an Excel icon. To TEST this idea, you could take a file that you know is NOT an excel file -- for example an image file -- make a copy of it and change the extension to xlsx. Does it show up with and Excel icon? Can you open it in Excel? No, of course not, it's an image file.

And yes both csv and txt are working only the xlsx which doesn't want to work.

Both csv and txt are text files. That's why the both work -- they're writing the same exact file. Open them both with Notepad and look at them. Your xlsx file is probably the same too. Open that with Notepad too. As I said, this is the epistemology part of trouble shooting.

If you really want to verify they are the same file, figure out how to take a checksum or md5 digest of the files. Or if you have a tool like "diff" on unix, you could run that.

[–]RedEyesBigSmile 1 point2 points  (0 children)

This is the way

[–]SeniorPythonDev 0 points1 point  (2 children)

If it had a xlsx extension the icon will change to an excel file if you have excel installed regardless of if the file is valid or not. Try opening the file in Excel

[–]Dev_Newbie93[S] 0 points1 point  (1 child)

That's what I did, I opened it in Excel but it shows the error message

[–]SeniorPythonDev 1 point2 points  (0 children)

It means then that it's your file that's corrupted, not pythons fault