Importing World City CSV File Into Roblox Studio

Hello, I am Peter. I have recently found a file that contains a good amount of the cities in the world, with their population, position, and name for my game. I am currently struggling to find a way to implement this CSV file/data sheet, with all of the data into Roblox Studio.

I have recently been placing the cities by hand in my game before I found out about this file. I had to search up the population, name, and I had to place them in an accurate location myself.

Here is an example of what I want to achieve, This is a picture of the cities I placed by hand. The color and size does not need to be set, I have a script that will automatically set those.
image

If you have any solutions, or ideas please let me know.

Thank you for reading,
-Peter :+1:

1 Like

This is what the spread sheet looks like btw

1 Like
local CSV =
[[
]] --paste it in plaintext here *inside the brackets

local linePattern = "[^\r\n]+"
local csWordPattern = "[^,]+"

function parseCsv(csv)
	local rows = {}

	for line in string.gmatch(csv, linePattern) do
		local row = {}

		for word in string.gmatch(line,csWordPattern) do
			table.insert(row, word)
		end
		
		task.wait()
		table.insert(rows, row)
	end

	return rows
end

for _,i in parseCsv(CSV) do --parse through the CSV
--do what you need
end
2 Likes

By the way, you should mark J9White’s answer as Solution. There should be a grey box in the bottom left corner of his answer that says “Solution.” Try clicking it.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.