Skip to content

Instantly share code, notes, and snippets.

@exemplum100
Created July 16, 2023 09:44
Show Gist options
  • Save exemplum100/238a7939a0334bd2fcae6e29a10520fc to your computer and use it in GitHub Desktop.
Save exemplum100/238a7939a0334bd2fcae6e29a10520fc to your computer and use it in GitHub Desktop.
Formatting to insert
# data for insert only one column
# ex: ('248957'),('248959'),('248960'),('248961'),('248962')
x='''248957
248959
248960
248961
248962
248963
248964
552416
'''
def formz(x):
y=x.rstrip().replace('\n','\'),(\'') # '\n','\',\'' '\n',','
y='(\''+y+'\')'
return y
with open('SQLinsertval.txt', 'wt') as xfile:
xfile.write(formz(x))
xfile.close()
print('SQLinsertval.txt done!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment