Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15582 > unrolled thread
| Started by | Francisco Gutierrez <fgutiers2002@yahoo.com> |
|---|---|
| First post | 2013-10-03 04:00 +0000 |
| Last post | 2013-10-07 12:22 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
small string issue Francisco Gutierrez <fgutiers2002@yahoo.com> - 2013-10-03 04:00 +0000
Re: small string issue Joe Gwinn <joegwinn@comcast.net> - 2013-10-04 02:09 +0000
Re: small string issue David Bailey <dave@removedbailey.co.uk> - 2013-10-07 12:22 +0000
| From | Francisco Gutierrez <fgutiers2002@yahoo.com> |
|---|---|
| Date | 2013-10-03 04:00 +0000 |
| Subject | small string issue |
| Message-ID | <l2iq4j$qmj$1@smc.vnet.net> |
Dear group:
I am importing into Mathematica a big number of dates. For example:
unasfechas = {11/06/1998, 21/01/2010, 12/10/2001, 20/07/2009,
02/02/2002, 02/01/2004, 19/11/2001, 14/02/2010, 26/12/2009,
20/10/1996, 09/07/2006, 01/01/1997, 30/08/1998, 15/02/2006,
13/12/2009, 25/09/2002, 29/06/2009, 02/04/2010, 22/02/2001,
01/04/2010}
These dates come from Excel files, and are brought into Mathematica not as strings but as numbers. I want to transform them into strings to
be able to apply functions like DateList, etc.
In principle, this should be easy. This example, taken from the documentation, is simple and clear:
ToString[x^2, InputForm]
Which returns a workable string.
However:
ToString[unasfechas[[1]], InputForm]
returns
11/11988
also a string but after applying an operation to what it considers the denominator.
how should I proceed
Thanks
Francisco
[toc] | [next] | [standalone]
| From | Joe Gwinn <joegwinn@comcast.net> |
|---|---|
| Date | 2013-10-04 02:09 +0000 |
| Message-ID | <l2l815$4vl$1@smc.vnet.net> |
| In reply to | #15582 |
In article <l2iq4j$qmj$1@smc.vnet.net>, Francisco Gutierrez
<fgutiers2002@yahoo.com> wrote:
> Dear group:
>
> I am importing into Mathematica a big number of dates. For example:
>
>
> unasfechas = {11/06/1998, 21/01/2010, 12/10/2001, 20/07/2009,
> 02/02/2002, 02/01/2004, 19/11/2001, 14/02/2010, 26/12/2009,
> 20/10/1996, 09/07/2006, 01/01/1997, 30/08/1998, 15/02/2006,
> 13/12/2009, 25/09/2002, 29/06/2009, 02/04/2010, 22/02/2001,
> 01/04/2010}
>
>
> These dates come from Excel files, and are brought into Mathematica not as
> strings but as numbers. I want to transform them into strings to
> be able to apply functions like DateList, etc.
>
> In principle, this should be easy. This example, taken from the
> documentation, is simple and clear:
> ToString[x^2, InputForm]
>
>
>
> Which returns a workable string.
>
> However:
> ToString[unasfechas[[1]], InputForm]
>
>
> returns
> 11/11988
>
> also a string but after applying an operation to what it considers the denominator.
>
> how should I proceed
It may be simpler to use the Excel date numbers and convert into the
corresponding numbers in Mathematica. How Excel encodes dates is explained in
the Excel documentation. Likewise Mathematica.
Joe Gwinn
[toc] | [prev] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2013-10-07 12:22 +0000 |
| Message-ID | <l2u92t$olj$1@smc.vnet.net> |
| In reply to | #15582 |
On 03/10/2013 05:00, Francisco Gutierrez wrote:
> Dear group:
>
> I am importing into Mathematica a big number of dates. For example:
>
>
> unasfechas = {11/06/1998, 21/01/2010, 12/10/2001, 20/07/2009,
> 02/02/2002, 02/01/2004, 19/11/2001, 14/02/2010, 26/12/2009,
> 20/10/1996, 09/07/2006, 01/01/1997, 30/08/1998, 15/02/2006,
> 13/12/2009, 25/09/2002, 29/06/2009, 02/04/2010, 22/02/2001,
> 01/04/2010}
>
>
> These dates come from Excel files, and are brought into Mathematica not as strings but as numbers. I want to transform them into strings to
> be able to apply functions like DateList, etc.
>
> In principle, this should be easy. This example, taken from the documentation, is simple and clear:
> ToString[x^2, InputForm]
>
>
>
I wonder what exactly you mean by "are brought into Mathematica"?
If you mean that you have used cut and paste (the way you phrase your
question suggests that), the solution is fairly easy - because you still
have the date digits available.
Instead of pasting the dates inside {}, paste them inside quotes (or add
the quotes afterwards:
dates = "11/06/1998,21/01/2010,12/10/2001,20/07/2009,02/02/2002,02/01/\
2004,19/11/2001,14/02/2010,26/12/2009,20/10/1996,09/07/2006,01/01/\
1997,30/08/1998,15/02/2006,13/12/2009,25/09/2002,29/06/2009,02/04/\
2010,22/02/2001,01/04/2010"
Now you can split the dates up using the comma delimiters:
In[14]:= StringSplit[dates, ","]
Out[14]= {"11/06/1998", "21/01/2010", "12/10/2001", "20/07/2009", \
"02/02/2002", "02/01/2004", "19/11/2001", "14/02/2010", "26/12/2009", \
"20/10/1996", "09/07/2006", "01/01/1997", "30/08/1998", "15/02/2006", \
"13/12/2009", "25/09/2002", "29/06/2009", "02/04/2010", "22/02/2001", \
"01/04/2010"}
If that doesn't help, please explain exactly how you brought those
numbers into Mathematica.
David Bailey
http://www.dbaileyconsultancy.co.uk
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web