1. Windows Central Question's Avatar
    Hello, here's my programme.
    (I'm french but I try to write english).
    I explain what I want to do in comments, but I summarize the goal :
    Here an extract of one of my text files :

    Suj01_PI_DP_C00_1
    Date:,2014/11/06
    Time:,14:55:12
    Type:,test
    Description:,""
    Notes:,""

    TRAJECTORIES
    100.000000,Hz
    ,Suj01:RIAS,,,Suj01:LIAS,,,Suj01:LIPS,,,Suj01:RIPS,,,Suj01:DSTR,,,Suj01:C7,,,Suj01:RACR,,,
    Field #,X,Y,Z,X,Y,Z,X,Y,Z,X,Y,Z,X
    1,-242.807816,1106.551270,1097.119385,14.437944,1075.778687,

    I want to extract datas from a text file to a matrix in Unity. For that, I create a matrix and I integrate all datas in it. Then, I want to load (read) the file but only from the 12th line. And I have to extract only 1 line / 4 of datas.

    I want the matrix doesn't load "1," which indicates the line's number of datas. And it's wrote at every line : "2,", "3," , ...

    Then, I want to integrate the name of items "Suj01:RIAS", "Suj01:LIAS", ... (There are more than 55 names like them) in a string. The same thing for the positions "X", "Y", "Z".
    Every group of three datas (separated by a comma) corresponds to a name in the order. The firt group corresponds to "Suj01:RIAS" for example. And every data in a group, corresponds to a position according to X, Y and Z, in the order. The first data corresponds to X, the second data to Y and the third to Z. For every group of 3 datas.

    Could you see my programme and tell me where there is a problem ?

    Here my programme :

    using System.Collections.Generic;
    using System.Text;
    using System.IO;
    using System.Collections;
    using System.Text.RegularExpressions;

    public class Recup_donnees_3 : MonoBehaviour {



    // When the script instance is being loaded
    void Awake () {

    Application.targetFrameRate = 25; // J'indique que la frquence est de 25 Hz
    }

    class FileReader

    {

    static void Main()

    {

    // ------------- This first part allows me to read in the console and to load in a matrix 1 line / 4 from the 12th line of the text file to the end ------------- //

    // Create an instance of StreamReader to read from a file

    StreamReader reader = new StreamReader ("Suj01_PI_DP_C00_1.txt");


    using (reader) { // Automatic Closing of the Stream after working with it , otherwise we would have to write "reader.Close" at the end to close the stream, beneath the last command's line of this part "class FileReader"

    int lineNumber = 12;



    // Read 12th line from the text file

    string line = reader.ReadLine ();



    // Read the other lines from the text file : 1 line / 4

    while (line != null) {

    lineNumber = lineNumber + 4;

    // Console.WriteLine("Line {0}: {1}", lineNumber, line); // To show in the console

    line = reader.ReadLine ();

    string[] Matrice_Suj01_PI_DP_C00_1; // To create a matrix which contains 1 line / 4 from text file

    Matrice_Suj01_PI_DP_C00_1 = reader.ReadLine (); // To indicate what datas will be loaded in this matrix named "Matrice_Suj01_PI_DP_C00_1"

    }

    // ------------- This second part allows me to extract some datas from the text file ------------- //

    // To separate every group of 3 datas corresponding to a one "marqueur"

    string[] values_position_X_Y_Z = Matrice_Suj01_PI_DP_C00_1.Split(',',3); // Pb : we can't use "Split" when it's a string []

    // To extract the axes positions (X Y Z) and to integrate them in a string

    int line_axes = 11;

    line_axes = reader.ReadLine ();

    string line_11;

    line_11 = reader.ReadLine ();

    string[] axes = line_11.Split(new char[] {'Filed #',','}); // Every axe is separating by ',' and the first is writing behind 'Filed #,'

    // To extract the names of "marqueurs" and to integrate them in a string

    int line_names = 10;

    line_names = reader.ReadLine ();

    string line_10;

    line_10 = reader.ReadLine ();

    string[] names = line_10.Split(new char[] {',',',,,'}); // Every name is separating by ',,,' and the first is writing behind ','

    // ------------- This third part allows me to indicate column's name "Positionnements des marqueurs : RIAS, LIAS, ..." for every group of 3 positions (every group X,Y,Z)------------- //

    // To indicate the correspondance between these strings : "values_position_X_Y_Z" and "names"

    string[] names = String.Join("/", values_position_X_Y_Z, 2, 3); // From the second data after "," from the 12th line, I associate 3 datas with the 10th line
    }
    }
    }

    }
    02-26-2015 03:44 AM
  2. Muessig's Avatar
    Honestly you're going to get better feedback if you register and post this in the Developer Forum.
    RumoredNow and Laura Knotek like this.
    02-26-2015 12:32 PM

Similar Threads

  1. Media Center from UNETA = Its One Gorgeous App
    By Jazmac in forum Microsoft Surface for Windows RT
    Replies: 4
    Last Post: 06-01-2015, 09:32 AM
  2. Text Message backup
    By Daniel Ashbaugh in forum Windows Phone 8.1 Preview for Developers
    Replies: 7
    Last Post: 02-26-2015, 10:32 AM
  3. Impressed With Video Texting
    By Aaron_Jones in forum Nokia Lumia 1520
    Replies: 0
    Last Post: 02-25-2015, 06:15 PM
  4. How do I download music from a flash drive to my car media center?
    By Windows Central Question in forum Ask a Question
    Replies: 1
    Last Post: 02-25-2015, 02:37 PM
  5. Is there a Windows phone app to download and fill in pdf files?
    By Windows Central Question in forum Ask a Question
    Replies: 1
    Last Post: 02-25-2015, 02:08 PM
LINK TO POST COPIED TO CLIPBOARD