I am trying to import data from a file. If I import a CSV file, I get:
For example, two curly brackets.
If importing from a .xlsx file I get an extra curly bracket like:
Why does this happen?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.Sign up to join this community
Import["file.csv"] imports a CSV file, returning an array.
Import["file.xlsx"] imports all sheets of an XLSX file, returning the result as a list of arrays.
If the file contains a single sheet, you can eliminate the extra curly braces using the second argument of
Import as in @bobthechemist's answer, or simply using
As mentioned in the comments and the documentation, importing from Excel files allows for multiple sheets. Thus, a single-sheet file will have what you refer to as an "extra" pair of curly braces. To eliminate this behavior, use:
The above command will import just the first datasheet.