473,480 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Reading in a arff file

2 New Member
Hey guys,

I cant seem to figure this one out and I looked everywhere for it. My question is how do I read this line of text from an input file into an array

@attribute outlook {sunny, overcast, rainy}

I want to put the word outlook, sunny, overcast, and rainy into an array or just atleast into strings but without the "{" and the ",". I am writing this in c++.

Any suggestions would be appreciated. Thanks
Feb 19 '07 #1
3 4371
sicarie
4,677 Recognized Expert Moderator Specialist
Hey guys,

I cant seem to figure this one out and I looked everywhere for it. My question is how do I read this line of text from an input file into an array

@attribute outlook {sunny, overcast, rainy}

I want to put the word outlook, sunny, overcast, and rainy into an array or just atleast into strings but without the "{" and the ",". I am writing this in c++.

Any suggestions would be appreciated. Thanks
You could do them individually. As long as you didn't have too many...
attribute[i] = "sunny"
attribute[i+1] = "overcast"
etc...
Feb 19 '07 #2
Ganon11
3,652 Recognized Expert Specialist
I think his question is not so much how to get the array working, but how to read that line from a file and be able to separate the words from each other.

I'd start by reading the line into a string variable, and then using .find() to find the 'limits' of each word - for example, to get outlook, you know it is between a space and a '{', so you can use .find() and .substr() to isolate that word.
Feb 19 '07 #3
sicarie
4,677 Recognized Expert Moderator Specialist
I think his question is not so much how to get the array working, but how to read that line from a file and be able to separate the words from each other.

I'd start by reading the line into a string variable, and then using .find() to find the 'limits' of each word - for example, to get outlook, you know it is between a space and a '{', so you can use .find() and .substr() to isolate that word.
That makes much more sense - I got confused with the notation, as that's how you represent an array in PERL.
Feb 19 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

20
32983
by: sahukar praveen | last post by:
Hello, I have a question. I try to print a ascii file in reverse order( bottom-top). Here is the logic. 1. Go to the botton of the file fseek(). move one character back to avoid the EOF. 2....
30
4534
by: siliconwafer | last post by:
Hi All, I want to know tht how can one Stop reading a file in C (e.g a Hex file)with no 'EOF'?
21
6355
by: EdUarDo | last post by:
Hi all, I'm not a newbie with C, but I don't use it since more than 5 years... I'm trying to read a text file which has doubles in it: 1.0 1.1 1.2 1.3 1.4 2.0 2.1 2.2 2.3 2.4 I'm doing...
11
3555
by: Freddy Coal | last post by:
Hi, I'm trying to read a binary file of 2411 Bytes, I would like load all the file in a String. I make this function for make that: '-------------------------- Public Shared Function...
8
3196
by: Lonifasiko | last post by:
Hi, Using Process class I asynchronously launch an executable (black box executable) file from my Windows application. I mean asynchronously because I've got an EventHandler for "Exited" event....
4
11081
by: archana | last post by:
Hi all, I want to read csv file into datatable. Is there any csv reader and writer available for freeware. I am reading csv file using schema.ini file. I don't want this dependency. The...
7
4527
by: tackleberi | last post by:
hi, im having some trouble reading a file into java and then storing it in an array here the code i have so far: import java.io.FileNotFoundException; import java.io.FileReader; import...
2
2410
by: Srinivas3279 | last post by:
I am new to the C/C++ My Program: int main(int argc, _TCHAR* argv) { //Declarations FILE *fp;
2
2687
by: sachinwadi | last post by:
Hi, Sachin here. I have a problem with XML using with VB6.0. I Have a XML file of size nearly 129MB. I am reading the file using XML DOM object and the retrieved record i am inserting into...
2
1695
by: electromania | last post by:
Hi, Im reading a file, with 2 columns. this is working as Im reading I want to be able to count how many rows I've read and also add the all values as im reading from the second column, could...
0
7103
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
6758
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
7010
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
5362
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,...
1
4799
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
4499
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
3011
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1311
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
572
muto222
php
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.