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 7788009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:51:20+00:00 2026-06-01T20:51:20+00:00

I am trying to read multiple binary (365)files and do some calculations then read

  • 0

I am trying to read multiple binary (365)files and do some calculations then read to another folder. I faced 2 problems:

First: The code below gives me an error:

Warning message: closing unused connection 3 (C:\PHD\Climate Data\Out\Temperature_1.dat

setwd("C:\\PHD\\Climate Data\\Wind\\")
listfile<-dir()
for (i in c(1:365)) {
  conne <- file(`listfile[i], "rb")
  file<- readBin(conne, integer(), size=2,  n=360*720, signed=T)
  file<-file-273.15 #
  close(conne)
  to.write = file(paste("C:\\PHD\\Climate Data\\Out\\Temperature_",i,".dat",sep=""),"wb")
  writeBin(file, to.write)
  close(to.write) 
}

Second:
As my files are 16bit,size=2, I wanted to make sure that my output data have the same size. So I just added size=2 to writeBin(file, to.write, size=2) but this gave an error:

Error in writeBin(file, to.write, size = 2) :   size 2 is unknown on this machine.            

Any help on writing binary files properly is appreciated

  • 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-01T20:51:22+00:00Added an answer on June 1, 2026 at 8:51 pm

    Based on what I can see you are trying to writeBin() a vector of doubles forcing each element to be of size 2. That is not possible.

    You may be able to as.integer(file) and try to write the resulting vector as elements of size=2 but you’ll have to try this.

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

Sidebar

Related Questions

I am trying to read multiple files in R from the working directory and
Using Python (3.1 or 2.6), I'm trying to read data from binary data files
I'm trying to read multiple files that have been serialized with ProtoBuf.NET using .NET
I'm trying to read in multiple files using MPI-IO in C. I'm following this
So essentially I am trying to read lines from multiple files in a directory
I want to read multiple RSS feeds using jQuery. I'm trying to write a
Iam trying to read a binary file to memory and pass the starting address
I'm currently trying to read in an XML file, make some minor changes (alter
Trying to figure out how to read in multiple variables through a file. for
I'm trying to read an entire stream (multiple lines) into a string. I'm using

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.