473,403 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

reading from a file without actually writing into its hard disk copy

Hi,

I have an array of data (which I am getting from a socket connection).
I am working on a program which acts on this data but the program is
written to work on data from a file (not from an array). I cannot
change anything in the program but can add some features by which I
can convert this array of data into a file. The easiest thing would be
to write the data into a file (in hard disk) and use it. But I will be
working on thousands of such data, so this would be time consuming.

One more constraint is that, the data has to be written into a file in
binary format and read in ascii format (otherwise the data is not read
properly). Is there anyway I can achieve this (writing in binary
format and reading in ascii format) without actually writing the array
into harddisk (by just using RAM).

Thanks
Jeevan.
Nov 13 '05 #1
2 3042

"Jeevan" <kj***********@yahoo.com> wrote in message
The easiest thing would be to write the data into a file (in hard disk)
and use it. But I will be working on thousands of such data, so this
would be time consuming.
tmpfile() is your friend. This is almost always implemented as a RAM file.
One more constraint is that, the data has to be written into a file in
binary format and read in ascii format (otherwise the data is not read
properly). Is there anyway I can achieve this (writing in binary
format and reading in ascii format) without actually writing the array
into harddisk (by just using RAM).

Unfortunately now you're in trouble, since you can't open a temporary file
as binary for writing and text for reading. The real solution is to change
your program design so that this isn't necessary.
Nov 13 '05 #2
Well, if you're in Unix/Linux, maybe you can use function "mmap".
The system call mmap() establishes a mapping between your process's
address space and a file.
You could map your file into RAM, then place your array on that memory
address.
But, maybe your data should be formated as ascii .....

Scott
"Jeevan" <kj***********@yahoo.com> wrote in message
news:a6*************************@posting.google.co m...
Hi,

I have an array of data (which I am getting from a socket connection).
I am working on a program which acts on this data but the program is
written to work on data from a file (not from an array). I cannot
change anything in the program but can add some features by which I
can convert this array of data into a file. The easiest thing would be
to write the data into a file (in hard disk) and use it. But I will be
working on thousands of such data, so this would be time consuming.

One more constraint is that, the data has to be written into a file in
binary format and read in ascii format (otherwise the data is not read
properly). Is there anyway I can achieve this (writing in binary
format and reading in ascii format) without actually writing the array
into harddisk (by just using RAM).

Thanks
Jeevan.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ishekar | last post by:
Hi, I have an application where i want to write data to a file, the data is being sent from an external source. I know the total size of the data and then i retrieve the data in small segments...
9
by: Jon LaBadie | last post by:
Suppose I'm using stdio calls to write to a disk file. One possible error condition is no space on file system or even (in unix environment) a ulimit of 0 bytes. Which calls would be expected to...
8
by: Vijay | last post by:
Hi. I have a binary file which is on a CD it has filesize around 300 MB. Its not a text file. I want to read it and copy its content to a new file on hard disk. I dont want to use filecopy. I...
8
by: Peter | last post by:
I'm trying to write a proceedure that will delete a file completely off a hardrive. I just don't want to kill the file. I want to rewrite over the data with 1's and 0's 8 times. Anyone have an...
3
by: noridotjabi | last post by:
Say I'm writting a program. In this program for some reason I need to store data somewere were I will be able to access it again. I don't want to store it in a file because then it could be...
5
by: thewritersclub | last post by:
Hi guys! I'm new to python so please be aware that I'm probably missing the obvious. Here's my problem... Traceback (most recent call last): File "<pyshell#37>", line 1, in <module> f =...
7
by: ianenis.tiryaki | last post by:
well i got this assignment which i dont even have a clue what i am supposed to do. it is about reading me data from the file and load them into a parallel array here is the question: Step (1) ...
4
by: ramyakrishnakumar | last post by:
Hi All, I am facing some problem with basic file operation... I have one xml file looks like <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <x:recording> <udf3>Gélin</udf3> ...
12
by: glennanthonyb | last post by:
Hi The company I work for has finally woken up to data security on our field laptops. I'm writing something in C# that will allow remote deletion of sensitive data and I don't believe...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.