Python Forum
How to put together datas into a file?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to put together datas into a file?
#2
Well, val_dB is a float. You explicitly made it one on the second line (although given that you made it a float and then made it a string on the previous line, I'm a little confused as to the process). Floats don't add to strings, you need to convert it back to string to do that:

myfile.write(date_ID + " " + val + str(val_dB) + "\n")
Better yet is to use string formatting:

myfile.write('{} {}{}\n'.format(date_ID, val, val_dB)
That will do the conversion for you, and allows for all sorts of ways to format the resulting string. You can see the full format method syntax here.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
How to put together datas into a file? - by Krszt - Nov-07-2018, 08:52 AM
RE: How to put together datas into a file? - by ichabod801 - Nov-07-2018, 04:06 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  time setup for realtime plotting of serial datas at high sampling rate alice93 6 3,951 Jan-07-2022, 05:41 PM
Last Post: deanhystad
  iterate and print json datas enigma619 1 1,973 Apr-01-2020, 11:48 AM
Last Post: buran
  Datas are not insert into database aravinth 1 2,258 Dec-21-2019, 04:17 PM
Last Post: buran
  Plotting datas Krszt 2 2,452 Oct-31-2018, 03:29 PM
Last Post: Davis4109
  How to put together datas from different files Krszt 3 2,459 Oct-31-2018, 07:37 AM
Last Post: Krszt
  How to write datas into a file? Krszt 2 2,463 Oct-25-2018, 01:45 PM
Last Post: Krszt
  how to retrieve datas with Overpass API python wrapper apollo 0 2,957 Oct-15-2017, 02:27 PM
Last Post: apollo

Forum Jump:

User Panel Messages

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