Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: eliminate some characters inside a file

  • To: mathgroup at
  • Subject: [mg34726] RE: [mg34716] eliminate some characters inside a file
  • From: "DrBob" <majort at>
  • Date: Mon, 3 Jun 2002 01:46:49 -0400 (EDT)
  • Reply-to: <drbob at>
  • Sender: owner-wri-mathgroup at

My solution seems unnecessarily complicated, but here goes...

I'll convert all *.txt files in an input directory into new files in an
output directory.

inputDirectory = "Moreno";
outputDirectory = "Moreno2";

This reads one input file and writes the corresponding output file:

fixFile[input_String, output_String] :=
  Module[{x, in, out},
    Close /@ Streams[output];
    out = OpenWrite[output, FormatType -> OutputForm];
    Close /@ Streams[input];
    in = OpenRead[input];
    While[(x = Read[in, String]) =!= EndOfFile,
      Write[out, StringJoin[DeleteCases[Characters[x], "\""] /. "," -> "
    Close /@ {in, out}

Apply fixFile to all files in the input directory, placing identically
named files in the output directory:

        StringDrop[#, StringLength[DirectoryName[#]]]]] & /@ 
  FileNames["*.txt", inputDirectory]

Bobby Treat

-----Original Message-----
From: A.M. [mailto:moreno at] 
To: mathgroup at
Subject: [mg34726] [mg34716] eliminate some characters inside a file

Hi everybody,

this is my question: I´ve got a large numbers o files with the next


and I need Mathemathica to eliminate " " and changes , by blank space to
obtain the next:
12 56 12 14
13 56 25 36
14 58 465 7
If anybody can help me I would be very pleased


  • Prev by Date: Re: repeated entries in File>Palettes menu (again)
  • Next by Date: RE: Package problem
  • Previous by thread: RE: eliminate some characters inside a file
  • Next by thread: Re: eliminate some characters inside a file