iccaros Posted March 9, 2007 Report Share Posted March 9, 2007 ok I have this file I need to turn into an array so I can then use some numbers to set up a 3d array but that really does not matterthe files seams to be tab separated values along with carrage returns that need striped out. I used this(FYI tr = TextReader)string[] Split = tr.ReadToEnd().Split(new char [] {'\t'});I have also tried using a tabkey for the charany idealsnote code is messy as I am testing different ideals/* * Created by SharpDevelop. * User: huskeyw * Date: 3/9/2007 * Time: 8:57 AM * * To change this template use Tools | Options | Coding | Edit Standard Headers. */using System;using System.Collections.Generic;using System.IO;namespace file{ class MainClass { public static void Main(string[] args) { string filenameWrite = "savdata.txt"; string filenameRead = "tldatanew.txt"; try { FileStream fs = new FileStream(filenameRead, FileMode.Open); // FileStream fs2 = new FileStream(filenameWrite, FileMode.Append); TextReader tr = new StreamReader(fs); // TextWriter tw = new StreamWriter(fs2); List<double> output = new List<double>(); try { string temp = ""; string[] Split = tr.ReadToEnd().Split(new char [] {'\t'}); for (int x = 0; x < Split.Length; x++) { Console.WriteLine(Split[x]); temp += Split[x]; Console.ReadKey(); //temp = temp.Split(new char [] {'a', 'b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','%'}); //Console.WriteLine(temp); } } finally { fs.Close(); //fs2.Close(); } } catch { Console.WriteLine("File not found"); } Console.ReadKey(); } } }file is attachedtldatanew.txt Quote Link to post Share on other sites
jcl Posted March 10, 2007 Report Share Posted March 10, 2007 Hmm. The attachment is space-separated values. Did the board eat the tabs? Quote Link to post Share on other sites
iccaros Posted March 10, 2007 Author Report Share Posted March 10, 2007 Hmm. The attachment is space-separated values. Did the board eat the tabs?hmm, I recived this from a diffrent company who states its tab seperted (which it seams since I did not check that it is spaces)but seperating on spaces gives me wierd stuff like100.003 insted of 100.003here is the first couple1.00100.001.00100.001.00100.003100.001.00100.003100.001.00100.003100.00320.001.00100.003100.00320.001.00100.003100.00320.005000.001.00100.003100.00320.005000.001.00100.003100.00320.005000.001001.00100.003100.00320.005000.00100thanks for the help, it works great from the c++ program we are moving to c++but it is vs 6 for c++, would that matter? Quote Link to post Share on other sites
iccaros Posted March 10, 2007 Author Report Share Posted March 10, 2007 Hmm. The attachment is space-separated values. Did the board eat the tabs?hmm, I recived this from a diffrent company who states its tab seperted (which it seams since I did not check that it is spaces)but seperating on spaces gives me wierd stuff like100.003 insted of 100.003here is the first couple1.00100.001.00100.001.00100.003100.001.00100.003100.001.00100.003100.00320.001.00100.003100.00320.001.00100.003100.00320.005000.001.00100.003100.00320.005000.001.00100.003100.00320.005000.001001.00100.003100.00320.005000.00100thanks for the help, it works great from the c++ program we are moving to c++but it is vs 6 for c++, would that matter?sorry I got it, I had converted the entire thing to a single string insted of each line it own array segment, it works now..sometimes my heads ends up in the wrong place.. Quote Link to post Share on other sites
iccaros Posted March 10, 2007 Author Report Share Posted March 10, 2007 ok now how do I remove empty lines from the array I have? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.