Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #14797 > unrolled thread

a trivial task?

Started byFrancisco Gutierrez <fgutiers2002@yahoo.com>
First post2013-06-11 06:22 +0000
Last post2013-06-12 09:26 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  a trivial task? Francisco Gutierrez <fgutiers2002@yahoo.com> - 2013-06-11 06:22 +0000
    Re: a trivial task? Helen Read <readhpr@gmail.com> - 2013-06-12 09:26 +0000

#14797 — a trivial task?

FromFrancisco Gutierrez <fgutiers2002@yahoo.com>
Date2013-06-11 06:22 +0000
Subjecta trivial task?
Message-ID<kp6fm8$nct$1@smc.vnet.net>
Friends:

Suppose I have a string variable, say:exp={"I do not", "understand", this"}
I want to export this variable to a text file, so that each part of exp is separated by a line (\n). Thus I want to get:I do notunderstandthis

How can I achieve this? Thanks

Francisco

[toc] | [next] | [standalone]


#14822

FromHelen Read <readhpr@gmail.com>
Date2013-06-12 09:26 +0000
Message-ID<kp9eso$2tb$1@smc.vnet.net>
In reply to#14797
First, fix the unmatched quotes in the last part of exp.

exp = {"I do not", "understand", "this"}

Use Riffle to insert a linebreak in between each part, and then use 
StringJoin to combine into a single string.

withbreaks=Riffle[exp, "\n"]

text=StringJoin[withbreaks]

Export["filename.txt", text]

I like to use SetDirectory[NotebookDirectory[]]
before importing/exporting, so that the directory is the same place 
where the working notebook is saved.


On 6/11/2013 2:22 AM, Francisco Gutierrez wrote:
> Friends:
>
> Suppose I have a string variable, say:exp={"I do not", "understand", this"}
> I want to export this variable to a text file, so that each part of exp is separated by a line (\n). Thus I want to get:I do notunderstandthis
>
> How can I achieve this? Thanks
>
> Francisco
>
>



[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web