docstr: Orders the rows in a csv according to the order specified on the server and saves it as a new file.
  
  Args:
      path_to_embeddings_csv:
          the path to the csv to order
  
  Returns:
      the filepath to the new csv
docstr_tok: ["Orders","the","rows","in","a","csv","according","to","the","order","specified","on","the","server","and","saves","it","as","a","new","file",".","Args",":","path_to_embeddings_csv",":","the","path","to","the","csv","to","order","Returns",":","the","filepath","to","the","new","csv"]
code: def _order_csv_by_filenames(
      self, path_to_embeddings_csv: str
  ) -> List[str]:
      """Orders the rows in a csv according to the order specified on the server and saves it as a new file.
  
      Args:
          path_to_embeddings_csv:
              the path to the csv to order
  
      Returns:
          the filepath to the new csv
  
      """
      with open(path_to_embeddings_csv, "r") as f:
          data = csv.reader(f)
  
          rows = list(data)
          header_row = rows[0]
          rows_without_header = rows[1:]
          index_filenames = header_row.index("filenames")
          filenames = [
              row[index_filenames] for row in rows_without_header
          ]
  
          filenames_on_server = self.get_filenames()
  
          if len(filenames) != len(filenames_on_server):
              raise ValueError(
                  f"There are {len(filenames)} rows in the embedding file, but "
                  f"{len(filenames_on_server)} filenames/samples on the server."
              )
          if set(filenames) != set(filenames_on_server):
              raise ValueError(
                  f"The filenames in the embedding file and "
                  f"the filenames on the server do not align"
              )
  
          rows_without_header_ordered = self._order_list_by_filenames(
              filenames, rows_without_header
          )
  
          rows_csv = [header_row]
          rows_csv += rows_without_header_ordered
  
      return rows_csv
  
file_path: lightly/lightly/api/api_workflow_upload_embeddings.py
imports: import csv
  import io
  import tempfile
  import urllib.request
  from datetime import datetime
  from typing import List
  from urllib.request import Request
  from lightly.api.utils import retry
  from lightly.openapi_generated.swagger_client.models import DatasetEmbeddingData, DimensionalityReductionMethod, Trigger2dEmbeddingJobRequest, WriteCSVUrlData
  from lightly.utils import io
label_desc: Use image node_id 6 for calling the _UploadEmbeddingsMixin obj's underlying member method code with example usage: obj._order_csv_by_filenames(path_to_embeddings_csv) and returns: rows_csv