How can i read large text file containing numbers with its index without first reading the hole datas? Is their any other method where i can directly save the datas to memory and than directly access it with its index like an array? If no how can i atleast read the datas very fast, the size of datas can be 300 mb to 1 gb. so reading the hole file fist is not suitable for performance. For example to write the data:
Code:
 rosbag::Bag bagr("test.bag", rosbag::bagmode::Write);
    for(int i=0;i<xw.size();i++)  {
       xo.data = xw.at(i);  bagr.write("numbers", ros::Time::now(), xo); 
       xo.data = yw.at(i);  bagr.write("numbers", ros::Time::now(), xo);
       xo.data = zw.at(i);  bagr.write("numbers", ros::Time::now(), xo); 
    }
And to read the same:
Code:
    rosbag::Bag bagr("test.bag");
    rosbag::View viewr(bagr, rosbag::TopicQuery("numbers"));
    BOOST_FOREACH(rosbag::MessageInstance const m, viewr)
    {
               std_msgs::Float32::ConstPtr i = m.instantiate<std_msgs::Float32>();
               iv = iv+1; 
               if(iv%3==0) {
                  x1.push_back(i->data);
               }
               if(iv%3==1) {
                 y1.push_back(i->data); 
               }
               if(iv%3==2) {
                 z1.push_back(i->data); 
               }
    }
    bagr.close();