<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Creating a Api links by url &amp; list from a saved df in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/creating-a-api-links-by-url-amp-list-from-a-saved-df/m-p/6925#M2923</link>
    <description>&lt;P&gt;@Kay Connolly​&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please check the below example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data = [{"ID": 1},
        {"ID": 2},
        {"ID": 3},
        {"ID": 4}
        ]
df = spark.createDataFrame(data)
&amp;nbsp;
for row in df.rdd.collect():
    print("https://apilink/locations/"+str(row["ID"]))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/476iD2DC2B9B0A689C8F/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Mar 2023 08:41:09 GMT</pubDate>
    <dc:creator>daniel_sahal</dc:creator>
    <dc:date>2023-03-29T08:41:09Z</dc:date>
    <item>
      <title>Creating a Api links by url &amp; list from a saved df</title>
      <link>https://community.databricks.com/t5/data-engineering/creating-a-api-links-by-url-amp-list-from-a-saved-df/m-p/6924#M2922</link>
      <description>&lt;P&gt;I have 106,000 + api's I need to call, so instead of calling them one by one I would like to create a loop as I have the list of location Id's which I've called from there api locations list and these will sit at the end of the url to get more info on each location as the location list is limited.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;e.g I want it to bring back all 106,000 api links from the 'IdColumn' from my loaded list&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.databricks.com/www.apilink/24582" target="test_blank"&gt;www.apilink/24582&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.databricks.com/www.apilink/24563" target="test_blank"&gt;www.apilink/24563&lt;/A&gt; ....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please see code below if anyone could help it would be so helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;from pyspark.sql.types import StructField, StructType, StringType, DataType, Row&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Idlist = spark.read.load("loadedfile.paquet")&lt;/P&gt;
&lt;P&gt;locid = Idlist.select('IdColumn')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LookUppy = str('&lt;A href="https://apilink/locations/" target="_blank"&gt;https://apilink/locations/&lt;/A&gt;') + str(Idlist['IdColumn'])&lt;/P&gt;
&lt;P&gt;print(LookUppy)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get this as the output =&lt;/P&gt;
&lt;P&gt;&lt;A href="https://apilink/locations/&amp;lt;'ldColumn'&amp;gt;" target="test_blank"&gt;https://apilink/locations/&amp;lt;'ldColumn'&amp;gt;&lt;/A&gt;;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Mar 2025 13:29:20 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/creating-a-api-links-by-url-amp-list-from-a-saved-df/m-p/6924#M2922</guid>
      <dc:creator>KayCon86</dc:creator>
      <dc:date>2025-03-21T13:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Api links by url &amp; list from a saved df</title>
      <link>https://community.databricks.com/t5/data-engineering/creating-a-api-links-by-url-amp-list-from-a-saved-df/m-p/6925#M2923</link>
      <description>&lt;P&gt;@Kay Connolly​&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please check the below example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data = [{"ID": 1},
        {"ID": 2},
        {"ID": 3},
        {"ID": 4}
        ]
df = spark.createDataFrame(data)
&amp;nbsp;
for row in df.rdd.collect():
    print("https://apilink/locations/"+str(row["ID"]))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/476iD2DC2B9B0A689C8F/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 08:41:09 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/creating-a-api-links-by-url-amp-list-from-a-saved-df/m-p/6925#M2923</guid>
      <dc:creator>daniel_sahal</dc:creator>
      <dc:date>2023-03-29T08:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Api links by url &amp; list from a saved df</title>
      <link>https://community.databricks.com/t5/data-engineering/creating-a-api-links-by-url-amp-list-from-a-saved-df/m-p/6926#M2924</link>
      <description>&lt;P&gt;Hi @Kay Connolly​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope everything is going great.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just wanted to check in if you were able to resolve your issue. If yes, would you be happy to mark an answer as best so that other members can find the solution more quickly? If not, please tell us so we can help you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Apr 2023 01:48:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/creating-a-api-links-by-url-amp-list-from-a-saved-df/m-p/6926#M2924</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-01T01:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Api links by url &amp; list from a saved df</title>
      <link>https://community.databricks.com/t5/data-engineering/creating-a-api-links-by-url-amp-list-from-a-saved-df/m-p/6927#M2925</link>
      <description>&lt;P&gt;@Kay Connolly​&amp;nbsp;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like you are trying to concatenate a string with a column object, which is causing the error. You need to convert the column object to a string first before concatenating it to the URL. Here's a modified code snippet that should work:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;from pyspark.sql.functions import concat_ws
&amp;nbsp;
Idlist = spark.read.load("loadedfile.paquet")
locid = Idlist.select('IdColumn')
&amp;nbsp;
# Convert the IdColumn to string and concatenate with the URL
lookup_urls = locid.withColumn('url', concat_ws('', 'https://apilink/locations/', locid.IdColumn.cast('string')))
&amp;nbsp;
# Show the resulting URLs
lookup_urls.show()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should create a new column called url that contains the complete API links for each location ID in your dataframe. You can then use this column to make the API calls in a loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Apr 2023 05:33:26 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/creating-a-api-links-by-url-amp-list-from-a-saved-df/m-p/6927#M2925</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-02T05:33:26Z</dc:date>
    </item>
  </channel>
</rss>

