If you have access to the original instrument software, this is the most reliable method for maintaining metadata integrity. Malvern PANalytical HighScore Plus : This is the native software for
If you prefer a graphic user interface over writing code, you can use specialized crystallographic file converters like .
extension. Once the software reads your data, you can save it back as an Instrument Data Collectors
: This professional software can be configured to read Excel files ( .csv , .xlsx ) by adding these extensions in the Program Settings > Automatic Processing menu, allowing you to then save them as .xrdml . Step-by-Step Conversion Methods Method 1: Using XRDlicious (Web-based) convert excel to xrdml high quality
Many XRD programs can read this .ASC file and then export it to .xrdml . Considerations for "Solid Piece" (Bulk) Samples
import pandas as pd import xml.etree.ElementTree as ET from xml.dom import minidom def excel_to_xrdml(excel_path, output_xrdml_path, sample_name="Unknown Sample"): # 1. Read the Excel file df = pd.read_excel(excel_path) # Assume Column 0 is 2Theta and Column 1 is Intensity angles = df.iloc[:, 0].tolist() intensities = df.iloc[:, 1].tolist() start_angle = angles[0] end_angle = angles[-1] num_points = len(angles) # Convert lists to space-separated strings required by XML arrays intensities_str = " ".join(map(str, [int(x) for x in intensities])) # 2. Build the XRDML XML structure root = ET.Element("xrdMeasurement", "xmlns": "http://panalytical.com", "status": "Completed" ) # Add Sample Metadata sample = ET.SubElement(root, "sample") id_elem = ET.SubElement(sample, "id") id_elem.text = sample_name # Add Scan Metadata xrd_scan = ET.SubElement(root, "scan", "scanAxis": "Gonio", "status": "Completed" ) data_points = ET.SubElement(xrd_scan, "dataPoints") # Add 2Theta Positions positions = ET.SubElement(data_points, "positions", "axis": "2Theta", "unit": "deg") start_elem = ET.SubElement(positions, "startPosition") start_elem.text = f"start_angle:.4f" end_elem = ET.SubElement(positions, "endPosition") end_elem.text = f"end_angle:.4f" # Add Intensities Array intensities_elem = ET.SubElement(data_points, "intensities", "unit": "counts") intensities_elem.text = intensities_str # 3. Pretty print and save the XML file to maintain high-quality encoding xml_string = ET.tostring(root, encoding="utf-8") parsed_xml = minidom.parseString(xml_string) pretty_xml = parsed_xml.toprettyxml(indent=" ") with open(output_xrdml_path, "w", encoding="utf-8") as f: f.write(pretty_xml) print(f"Successfully converted excel_path to high-quality XRDML at output_xrdml_path") # Example Usage: # excel_to_xrdml("diffraction_data.xlsx", "output_result.xrdml", "Catalyst_Batch_A") Use code with caution. Step 4: Validating Your Converted File
). If your Excel data has skipped points or overlapping ranges, your Rietveld software will throw an error. Clean up your steps in Excel using linear interpolation before exporting. If you have access to the original instrument
Your Excel file should have two columns:
Several open-source and professional tools can handle XRD data format transformations: PowDLL Converter
Ensure the first row of your CSV file is the first data point. Once the software reads your data, you can
# Create root element root = ET.Element('xrdml', 'xmlns': 'http://www.xrdml.com/XRDML', 'version': '1.0' )
# Create XRDML root element root = ET.Element('XRDML')
# Save XRDML file tree = ET.ElementTree(root) tree.write('example.xrdml', encoding='utf-8', xml_declaration=True)
Converting an Excel file to XRDML is not a standard "Save As" action; it is the act of building a comprehensive digital twin of your experiment. The most accessible route for most users is to use to import the CSV data and then export it as XRDML, ensuring the software handles the structural heavy lifting.