Python Forum
Creating a delimited file from DB Table
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a delimited file from DB Table
#8
(Sep-17-2018, 03:19 PM)volcano63 Wrote:
(Sep-17-2018, 01:28 PM)anubhav2020 Wrote: I tried the 'r' for raw string and did not make any difference. So I changed my code as follows.
[/python]

Looks like handling of backslash in strings has changed lately - I was not aware of that. It only breaks when backslash with the following character creates a defined escape sequence, e.g.
  • \n - line feed
  • \t - tabulation
  • \a - beep
  • \b - backspace
(for extended list - see table in Wiki)

Nevertheless, while that was not your problem, backslashes in string may cause an unintended behaviour, so - be careful with those. Pay attention how r prefix or double backslash change the string behaviour
Output:
In [111]: print('C:\location\noutput.dat', 'C:\location\\noutput.dat') C:\location output.dat C:\location\noutput.dat In [112]: print('C:\location\toutput.dat', 'C:\location\\toutput.dat') C:\location output.dat C:\location\toutput.dat In [113]: print('C:\location\aoutput.dat', r'C:\location\aoutput.dat') C:\locationoutput.dat C:\location\aoutput.dat In [114]: print('C:\location\boutput.dat', r'C:\location\boutput.dat') C:\locatiooutput.dat C:\location\boutput.dat In [115]: print('C:\location\x25output.dat', r'C:\location\x25output.dat') C:\location%output.dat C:\location\x25output.dat

After multiple attempts, it finally worked.
But the issue with large files running out of memory still persists. Any suggestions as to what cn be changed in the code!!
Reply


Messages In This Thread
RE: Creating a delimited file from DB Table - by anubhav2020 - Sep-19-2018, 05:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Tab Delimited Strings? johnywhy 7 720 Jan-13-2024, 10:34 PM
Last Post: sgrey
  Help creating shell scrip for python file marciokoko 10 1,522 Sep-16-2023, 09:46 PM
Last Post: snippsat
  Creating csv files from Excel file azizrasul 40 6,109 Nov-03-2022, 08:33 PM
Last Post: azizrasul
  Use module docx to get text from a file with a table Pedroski55 8 6,512 Aug-30-2022, 10:52 PM
Last Post: Pedroski55
  Converted Pipe Delimited text file to CSV file atomxkai 4 7,163 Feb-11-2022, 12:38 AM
Last Post: atomxkai
  Creating file with images BobSmoss 1 1,437 Jan-08-2022, 08:46 PM
Last Post: snippsat
  dataframe write to tab delimited differs from Excel koh 0 2,045 Aug-01-2021, 02:46 AM
Last Post: koh
  Yahoo_fin, Pandas: how to convert data table structure in csv file detlefschmitt 14 7,962 Feb-15-2021, 12:58 PM
Last Post: detlefschmitt
  write mariadb table rows query to each file? shams 1 1,972 Feb-02-2021, 04:10 PM
Last Post: buran
  Creating csv file from another file pisike 0 1,636 Nov-24-2020, 02:02 PM
Last Post: pisike

Forum Jump:

User Panel Messages

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