473,508 Members | 2,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

accessing csv file

Hi, I have software that records betfair data into a csv file. I have
no access to the code, al I can adjust is the intervals at which it
records, 1sec up, and which folder/file to save the data to. Ive
written some code myself which uses streemreader to read the file into
an array, which I then reverse as I only want the last 10-15 lines
entered in the file. I fire this code using a timer. My problem is
this: If the betfair software is set to update every 2 sec, and I set
my timer to fire every 3 secs, then at some point there will be a
clash accessing the file. This is infact what happens, sometimes it
takes 10minutes upon running, or straight away. Now it knocks the
betfair software out, but not mine because ineffect it just keeps
repeating the last line.
Is there away to tell my code to wait until file is free, asumming
betfair software is opening file, updating and closing, before
reading. Im thinking that when data's bieng written to the cv file,
its flaged to say its in use. I hope this makes sense.
Regards Robert
Dec 11 '07 #1
2 1631
How would the other software react if the file was missing? Would it
simply recreate? Basically, even reading the file is probably going to
cause the other software to have issues when it tries to open the file
for write. However, renaming the file (move) is a single atomic
operation that should succeed if the file is currently closed, or
throw an error otherwise (just wait for retry)... either way the other
software should be happier to carry on (or at least, collisions should
be rarer). Of course, you'd still need to handle merging these
contents with what you have already seen...

Also - reading everything into an array and reverse? Once you have the
data, you don't really need to reverse it to get the last entries -
just look at the indexes and ignore everything else. Better still -
when reading the data just keep a buffer of 15 rows. As you read data,
simply round-robin the buffer (and keep track of the cursor) and you
should have a very efficient store of 15 rows.

Alternatively, you could use FileSystemWatcher to observe the files
being edited, but you'd need to be sure to read it (and close it)
before the competing process tries to write to it again - otherwise
you will likely kill the other software.

For reading CSV, there is a good reader on CodeProject; it handles a
lot of the subtle format issues with CSV:
http://www.codeproject.com/KB/database/CsvReader.aspx
Dec 11 '07 #2
Thankyou for your reply, this gives me something to think about.
Regards Robert
Dec 11 '07 #3

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

Similar topics

3
2138
by: Paul Phillips | last post by:
Here is what I am trying to do. I have an application that is written in VB 6 and in this application it is accessing a custom dll file that was created using Microsoft Fortran Professional 4.0....
23
2879
by: Lamberti Fabrizio | last post by:
Hi all, I've to access to a network file from an asp pages. I've red a lot of things on old posts and on Microsoft article but I can't still solve my problem. I've got two server inside the...
3
4303
by: prodirect | last post by:
Hi all, I hope someone can help me. I've recently created a database and wanted to put it up on an ftp sight so that multiple people could access the same tables at the same time from different...
0
2241
by: Joergen Bech | last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running application on a web server outside of my control, but only the first time I run it: 1. After a long period of inactivity (or...
5
3034
by: Daniel Corbett | last post by:
I am trying to save a file dynamically created in a webpage. I get the following headers, but cannot figure out how to save the attachment. I am basically trying to replicate what internet...
4
3739
by: Khalique | last post by:
I have built a web service whose purpose is to copy files from a secure place to client machine and vice versa. The problem I am having is perhaps related to permissions and access rights. For...
3
4969
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
4
3599
by: raj_genius | last post by:
I hav two queries, whc are as follows: FIRSTLY: is it possible to access the controls(by name) of a parent form(MDI) from its child forms??if yes then how??plzz provide a coded example in VB if...
2
4497
by: Vincent | last post by:
I have been trying to find some API routines that will allow me to determine the name of the computer that is accessing a file on a server. I have found the NetFileEnum call (returns the names of...
4
4199
by: Noy B | last post by:
Hi, I have developed a small application that is using a MSAccess DB. the problem is that it was developed on a machine where the application and the DB are both located. now it needs to be...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7377
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...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7489
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...
1
5047
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...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.