- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2022 08:14 AM
Hello everyone, every day I extract data into xls files but the column position changes every day. Is there any way to find these columns within the file?
Here's a snippet of my code.
df = spark.read.format("com.crealytics.spark.excel")\
.option("header", "true")\
.schema(schema)\
.option("dataAddress", "'releases'!A27:D78") \
.load("dbfs:/FileStore/tables/invoice_september.xls")
df.display()
- Labels:
-
ColumnPosition
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 04:18 PM
You can also do df.printSchema() to check. Or even dbutils.fs.head(<file_path>) to check the header's position. Docs https://docs.databricks.com/dev-tools/databricks-utils.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 03:29 PM
Hi, Thanks for reaching out to community.databricks.com.
Please refer and let us know if this helps, you can find column names: https://sparkbyexamples.com/pyspark/pyspark-find-datatype-column-names-of-dataframe/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 04:18 PM
You can also do df.printSchema() to check. Or even dbutils.fs.head(<file_path>) to check the header's position. Docs https://docs.databricks.com/dev-tools/databricks-utils.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2022 10:20 PM
Hi @welder martins
Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.
We'd love to hear from you.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2022 05:07 AM
Hello, come shape. Thanks!

