where is the problem?

modify WriteFile this way:

1
2
3
4
5
6
7
8
9
10
let WriteFile (fn : string, txt: string[]) = 

   let streamer = new StreamWriter(fn) 

   for str in txt do

       streamer.Write(txt) 

   streamer.Close()

and pass your lines to it.

(insert tabs yourself)

By on 8/21/2011 11:53 PM ()

Thank you for the code.

How do I pass lines to it? I can make a simple string work but how do I pass a streamed file (streamReader) into the written file (streamWriter).

For now I just want to see if I can pass the stream read file into the newly created stream written file. Once I have that down then I can work on manipulated the data from the read file before it is insterted into the written file. i.e. read file > manipulate data into XML > write the XML into the new file.

Thanks again.

By on 8/22/2011 5:52 AM ()

Some variants is possible

the shortest:

1
2
WriteFile "c:/testtesttest.txt" File.ReadAllLines("c:\SALESFILE2.txt")

(The WriteFile has signature as in previous post).

More flexible variant:

1
2
3
4
let readFile fn = File.ReadAllLines(fn)

WriteFile "c:/testtesttest.txt" ( readFile "c:\SALESFILE2.txt")
By on 8/22/2011 9:57 PM ()

I tried these and they did compile.

It does write the file but when I open the file all that's listed in the file is "System.string[]" ....the actual output of the read file is not in the written file. ....only System.string[]

I had gotten to this level with my code as well...it wrote the file but the contents only said........System.string[].

....any ideas?

By on 8/23/2011 5:48 AM ()

in the code

1
2
for str in txt do
  streamer.Write(txt)

in second line replace "txt" with "str". Obvious mistake.

By on 8/24/2011 1:22 AM ()

I now know how to read a file and write it into another file. So next I want to be able to read a file > manipulate that file as it is being read > then write the manipulated data into the written file.

Here is my code for the read file and how I want to have the data manipulated.....how do I write the manipulated data into another file?

=============

let readFile =
let lines = File.ReadAllLines("c:\SALESFILE.txt")
let printLine (line: string) =
let items = line.Split([|'^'|])
printfn "\"%O\", \"%O\", \"%O\", \"%O\", \"%O\", \"%O\", \"%O\";"
items.[5]
items.[7]
items.[15]
items.[9]
items.[10]
items.[4]
items.[12]
Seq.iter printLine lines

do readFile

=================

Thanks,
robert

By on 8/29/2011 2:35 PM ()

Thank you dondublon10...

That worked!!!

I appreciate you taking the time to help me with this.

robert

By on 8/24/2011 2:40 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper