Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8724613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:52:02+00:00 2026-06-13T07:52:02+00:00

I am reading in data in the following format: {ok,Volts} = file:open(voltage1.dat,read). In the

  • 0

I am reading in data in the following format:

{ok,Volts} = file:open("voltage1.dat",read).

In the ‘voltage.dat’ file there is a single value which is converted into
the string

" 9.9944639227844667e-001\n". This should be assigned to the Volts variable.

In order to use the string_to_float function later I need to strip away the spaces
and remove the \n delimiter.

I have explored using string:strip, string:substr and re:replace library functions.

I am using the variable Volts as the input string when I try each of these, e.g:

string:substr(Volts,3,18).

This does not work. I think it is because of the way that I am
inputting the Volts variable.

Can anyone put me right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:52:03+00:00Added an answer on June 13, 2026 at 7:52 am
    {ok,Volts} = file:open("voltage1.dat",read).
    

    will just open the file; Volts is a file descriptor, not the file’s contents. In order to read the file you can use functions from the io module. Besides reading the whole file and then interpreting you can use fread/3:

    1> {ok, V} = file:open("voltage.dat",read).
    {ok,<0.34.0>}
    2> io:fread(V,'',"~f").
    {ok,[0.9994463922784467]}
    

    If you don’t want/can do that (maybe your file has a more complex format) remember that string are lists, therefore you can use filter/2 and other list functions

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a csv file which has following data format 14-Sep-12 ALUMINI 31-Dec-12
I'm reading from a binary data file which is written by invoking the following
I'm trying to read a binary file that is in the following format: number
My app downloads a file in UTF-8 format, which is too large to read
I have a file(both .dat and .txt format) which contains numbers(integers) in rows and
I am an array in following format. I am reading following data from a
Im reading from a file (data.bin) using the following approach - fis1 = new
My data is in following format: TABLE NUMBER 1 FILE: name_1 name_2 TIME name_3
I am reading in log data with the following time stamp format: Sat Aug
So I recently asked the following questions: Reading A Fixed Format Text File -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.