Convert MPP to CSV in Python | MPP File to CSV in Python

One common issue in project data management is having to deal with different file formats. Sometimes, if you are using files created in Microsoft Project format, you may need to convert an MPP file to CSV format for easier data manipulation. Microsoft Project uses the MPP file format to store the plans, schedules, tasks, timelines, resources, and the overall project management plan. However, the CSV format is more universal, and it is easy to import into other spreadsheet applications. In this blog post, we will learn how to convert MPP to CSV in Python.

This article covers the following topics:

  1. Convert MPP to CSV using the Python library
  2. Convert MPP to CSV: A Step-by-Step Guide
  3. Customize MPP to CSV Conversion in Python
  4. MPP to CSV: Changing the View
  5. MPP to CSV: Changing the Delimiter
  6. How to Hide Column Headers?
  7. Free Resources

Python Library to Convert MPP to CSV

We will use Aspose.Tasks for the Python library to convert MPP files into CSV format. It is a powerful library that allows for comprehensive project management tasks within Python.

Advantages of Using Aspose.Tasks for Python

  • Ease of Use: The library provides simple and intuitive methods for working with project files.
  • Comprehensive Functionality: Aspose.Tasks supports a wide range of project management tasks beyond file conversion.
  • Performance: The library optimizes performance to ensure quick and efficient file processing.

Installing Aspose.Tasks for Python

Before we dive into the code, let’s set up our environment. You’ll need to install the Aspose.Tasks library in your Python environment. Please download the package from downloads or install it directly from PyPI by running the following pip command in your console:

pip install aspose-tasks

Convert MPP to CSV: A Step-by-Step Guide

1. Import required libraries

First, import the necessary libraries for the conversion process.

import aspose.tasks as tasks

2. Load the MPP file

Next, load the MPP file using the Project class from the library. Ensure you have your MPP file ready in your working directory.

project = tasks.Project("sample.mpp");

3. Export MS Project to CSV

Finally, save the project as a CSV file using the save() method.

project.save("sample_out.csv", tasks.saving.SaveFileFormat.CSV);

That’s it! We have successfully converted the MPP file to a CSV format using Aspose.Tasks for Python.

MPP File to CSV Conversion: Complete Code

Here is the complete code example that shows how to convert MPP to CSV in Python.

Convert MPP File to CSV using Python

Convert MPP File to CSV using Python.

Customize MPP to CSV Conversion in Python

Aspose.Tasks provides the CsvOptions class for converting MPP files with non-default settings. This class allows you to specify additional options while rendering project pages in CSV format.

Customize the MS Project MPP file to CSV conversion using the CsvOptions class by following these steps:

  1. Load the MPP file using the Project class.
  2. Create an instance of the CsvOptions class.
  3. After that, define the CSV options, such as text_delimiter, etc.
  4. Finally, save the project as a CSV file using the save() method. It takes the output CSV file path and the CsvOptions as arguments.

The following sample code shows how to convert an MPP file to CSV with customized settings in Python.

MPP to CSV: Changing the View

When converting MPP files to CSV format, the default view that determines the column headings is the Gantt Chart view. However, if you want to control which columns to export, changing the DataCategory property will alter the view. This lets you set up new perspectives and refine the output to meet your needs.

We can easily customize the view by following the steps mentioned earlier. We only need to specify the data_category property, as shown in the code below:

MPP to CSV: Changing the Delimiter

CSV is a text-based data format where delimiters separate data fields. We can customize this delimiter by setting the TextDelimiter property to one of the following options:

  • Comma;
  • Semicolon (the default);
  • Space;
  • Tab.

You can find descriptions of these options in the CsvTextDelimiter enumeration. We can set the delimiter by following the steps mentioned earlier. We simply need to specify the text_delimiter property to split data fields, as illustrated in the code below:

MPP to CSV: How to Hide Column Headers?

When converting to CSV, it exports column headers by default. If you want to hide the column headers, simply use the IncludeHeaders property to suppress their export. This allows you to customize the CSV output to better meet your requirements.

Get a Free License

Please get a free temporary license to try the API without evaluation limitations.

Python MPP to CSV Converter: Free Resources

Besides converting MPP files to CSV in Python, explore various other features of the API using the following resources:

Conclusion

Converting MPP to CSV in Python is quite easy, as elaborated above in this article. You can leverage Aspose.Tasks for Python to export data from MS Project into a CSV format. By following the steps outlined here, you can effectively manage your project data and ensure smooth integration and analysis across different platforms.

Feel free to explore other products from Aspose. If you have any questions or need assistance, don’t hesitate to reach out to us in our free support forum.

See Also