0

Working on a data transfer program, to move data from an oracle database to another application that I cant see or change. I have to create several text files described below and drop them off on sftp site.

I am converting from a 20+ year old SQR report. (yes SQR) :(

I have to create text files that have a format as such an_alpa_code:2343,34533,4442,333335,.....can be thousands or numbers separated by comma.

The file may have only 1 line, but the file might be 48k in size.

There is no choice on the file format, it is required this way.

Tried using Oracle UTL_FILE, but that cannot deal with a line over 32k in length, so looking for an alterative. Python is a language my company has approved for use, so I am hoping it could do this

  • Does this answer your question? [How can I print multiple things on the same line, one at a time?](https://stackoverflow.com/questions/5598181/how-can-i-print-multiple-things-on-the-same-line-one-at-a-time) – Woodford Jan 24 '23 at 00:20
  • To extract data from Oracle DB in Python, use the python-oracledb driver. The documentation is [here](https://python-oracledb.readthedocs.io/en/latest/index.html). Code in [this answer](https://stackoverflow.com/a/75063284/4799035) might be useful to you. – Christopher Jones Jan 24 '23 at 22:02

2 Answers2

0

I too once [was forced] to use SQR many years ago, and so you have my sympathy.

python can definitely do this. If you set the end argument of the print command to an empty string, then you can ensure that no new line is output:

print("Hello world",end='')

perl could also be a good candidate language.

print("Hello world");

Both python and perl have Oracle client libraries.

joe90
  • 51
  • 4
  • Thank you very much for responding. how does the method apply to writing to OS file- – george fortech Jan 24 '23 at 15:20
  • Thank you very much for responding. how does the method apply to writing to OS file- such as if i was using (pseudo code) file_obj = open("writing.txt", "w") loop file_obj.write(myvariable) file_obj.write(",") end loop the loop will iterate a few thousand times thanks! – george fortech Jan 24 '23 at 15:38
  • haha actually the example i saw which said there would be new lines, didnt ad new lines so for i in range(0,10000): file_obj.write("mystuff"+str(i)+",") # file_obj.write('\n') file_obj.close() gave me one long line- just what i needed, thanks again! – george fortech Jan 24 '23 at 16:13
0

This gave me one long line file_obj = open("writing.txt", "w")

for i in range(0,10000): file_obj.write("mystuff"+str(i)+",") # file_obj.write('\n')

file_obj.close()