Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Writing to External File
#5
Not according to your error message. According to the error message the problem is here:
    output.write("%d %d %d" % (np.shape(kxx)[1], np.shape(kxx)[0], collapse_steps)
I am surprised this is not showing up as a syntax error because of the mismatched parenthesis. So I loaded the code into my editor and is says these parenthesis match.
with open(file_ls, "w") as output:
    output.write("%d %d %d" % (np.shape(kxx)[1], np.shape(kxx)[0], collapse_steps)  # expected ) here
for ii in np.arange(np.shape(kxx)[1]))  # Python says matching paren for write ( is end of this line
Now the message makes more sense. It sees the for loop inside the parenthesis for the argument list for the write() command and complains about the generator.
Reply


Messages In This Thread
Writing to External File - by DaveG - Mar-29-2022, 03:59 AM
RE: Writing to External File - by menator01 - Mar-29-2022, 06:27 AM
RE: Writing to External File - by bowlofred - Mar-29-2022, 06:32 AM
RE: Writing to External File - by DaveG - Mar-29-2022, 07:21 AM
RE: Writing to External File - by deanhystad - Mar-29-2022, 07:20 PM
RE: Writing to External File - by DaveG - Mar-29-2022, 11:07 PM
RE: Writing to External File - by bowlofred - Mar-30-2022, 12:46 AM
RE: Writing to External File - by DaveG - Mar-30-2022, 02:01 AM
RE: Writing to External File - by DaveG - Mar-30-2022, 02:18 AM
RE: Writing to External File - by bowlofred - Mar-30-2022, 06:25 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Writing string to file results in one character per line RB76SFJPsJJDu3bMnwYM 4 1,502 Sep-27-2022, 01:38 PM
Last Post: buran
  Writing to json file ebolisa 1 1,075 Jul-17-2022, 04:51 PM
Last Post: deanhystad
  Writing to file ends incorrectly project_science 4 2,820 Jan-06-2021, 06:39 PM
Last Post: bowlofred
  Problems Sorting Data in an External File (.txt) Superlegend21 1 4,396 Dec-27-2020, 10:06 PM
Last Post: Superlegend21
  Writing unit test results into a text file ateestructural 3 4,894 Nov-15-2020, 05:41 PM
Last Post: ateestructural
  Writing to file in a specific folder evapa8f 5 3,574 Nov-13-2020, 10:10 PM
Last Post: deanhystad
  Failure in writing binary text to file Gigux 7 3,924 Jul-04-2020, 08:41 AM
Last Post: Gigux
  writing data to a csv-file apollo 1 2,433 Jul-03-2020, 02:28 PM
Last Post: DeaD_EyE
  Writing to File Issue Flash_Stang 3 2,601 Jun-05-2020, 05:14 AM
Last Post: Gribouillis
  Help! Formatting and Writing to a File bwdu 2 2,475 Apr-19-2020, 09:29 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020