Mathematica Student Edition
Mathematica Home Edition
Computable Document Format (CDF)
Aerospace Engineering & Defense
Biotechnology & Medicine
Finance, Statistics & Business Analysis
Financial Engineering & Mathematics
Financial Risk Management
Software Engineering & Content Delivery
Authoring & Publishing
Social & Behavioral Sciences
Design, Arts & Entertainment
Game Design, Special Effects & Generative Art
STEM Education Initiative
Community & Technical College Education
Primary & Secondary Education
Computable Document Format (CDF)
High-Performance & Parallel Computing (HPC)
See Also: Technology Guide
Other Ways to Buy
Volume & Site Licensing
Does My Site Have a License?
Wolfram User Portal
About Wolfram Research
Stephen Wolfram's Home Page
Wolfram Functions Site
More Info >>
Mark as an Answer
Problem with big input not accepted
Import and Export
I'm new of this forum, congratulations for it!
I have a little problem: I need to process a lot of data (hundreds of thousands of lines of .txt, each line is about 150 char). I am using the trial version (30 days then expires) and Mathematica does not allow me to paste (not process, just paste) more than about a thousand lines. If I paste just one thousand and then the second thousand again it processes them, I just have a problem in pasting more than one thousand a time.
If I buy the 6 months licence will it accept bigger data as input? If yes, how big? Because I red that the trial version does not allow you to input from excel and so on, but I am actually just trying to paste them from the .txt file... do you think that it is a limitation of the trial version or will I have the same problem also with the licence?
With the full version you can use
so you wont even need to copy paste:
data = Import["data.txt", "Table"];
I bought the 6 months version and I can import the file from Insert->file->open but if I try with the Import it does not work, it says that it can't find the file. Is it probably because that the file isn't in the right directory? I've looked for an answer on the internet but found nothing... thanks!
Watch this video:
How to | Insert a File Path
Here is the summary.
I suppose you know where file is located in the directory. So, when using Import for exact path do the following.
Place cursor inside square parenthesis Import[|]
Go: Top menu >> Insert >> File path...
Browse to the file, select it and click button "Choose"
You will see complete path appearing inside Import. By the way, how big is the file size?
Thank you for the answers!
it is 4MB, 26k lines of 150 char each, but it will be bigger...
It makes the import now but it does not recognise it as a Table. If I copy paste Mathematica sees it as a Table, with the Import function no...
Here is a sample of my file:
That is not a big file at all. I would recommend browsing our extensive documetation system. For example, this tutorial can give you a few hints on how to get this working:
Importing and Exporting Data
this is what happens:
If you can give a clear simple explanation of what you want to accomplish and
put a copy of enough of your data in a place that anyone can get that without needing to sign up with some service then
perhaps someone can take a few minutes and write a few lines of code to help you get started.
My .txt file is something like
I would like mathematica to read it as a matrix such that, if I write
data=Import["data.txt"]; (or also data=Import["data.txt","Table"]; )
the output should be the matrix
1 2 3
4 5 6
ciao e f
the brackets and commas are in the right positions but mathematica does not reat it as a matrix 3x3 but as a matrix 3x1 as follows
Anybody knows why?!
Ah, that is very helpful. Thank you.
I create a sample text file containing a single line
I import using
Mathematica will often think it is being helpful by hiding many important details so I use
That shows me]
Using Fullform on an expression when something does not work is a very powerful trick and it will help you often if you remember it.
This shows that Mathematica read the file not as a matrix of numbers, but as a long string in quotes.
I try to turn the string into a matrix of numbers
which gives me
shows you your matrix.
I caution you, MatrixForm and FullForm and other "Form"s in Mathematica are good to look at the data,
but each of those has placed the information inside a "container" and new users are often confused
when they try to then do math operation on the output from FullForm or MatrixForm. If you want to do
operations on your matrix I would suggest you use
which will give you your data in a two dimensional list, but not contained inside FullForm formatting.
now it works thanks!!
Since the content of data.txt is a Mathematica expression, you can also import the file using "Package":
This returns the expression you need, without having to call ToExpression on the string.