@@ -1394,23 +1394,22 @@ def hasSpecialCharacter(input_string)
13941394
13951395 def generateCountryDatav7 ( )
13961396 ###
1397- filename = "data/cache/dumped-data.csv"
1398- new_file = !File . exist? ( filename )
1399- FileUtils . touch ( filename ) if new_file
1400- puts new_file ? "Created new file: #{ filename } " : "File already exists: #{ filename } "
1401- File . open ( filename , 'a' ) do |file |
1402- # Write headers if it's a new file
1403- if new_file
1404- headers = "countryCode,percentileBudget,totalBudget,iati_identifier\n "
1405- file . write ( headers )
1406- end
1397+ # filename = "data/cache/dumped-data.csv"
1398+ # new_file = !File.exist?(filename)
1399+ # FileUtils.touch(filename) if new_file
1400+ # File.open(filename, 'a') do |file|
1401+ # # Write headers if it's a new file
1402+ # if new_file
1403+ # headers = "countryCode,percentileBudget,totalBudget,iati_identifier\n"
1404+ # file.write(headers)
1405+ # end
14071406
1408- # 3.times do
1409- # # Generate a random line (you can customize this)
1410- # random_line = "#{rand(1..100)},#{rand(1..50)},#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}\n"
1411- # file.write(random_line)
1412- # end
1413- end
1407+ # # 3.times do
1408+ # # # Generate a random line (you can customize this)
1409+ # # random_line = "#{rand(1..100)},#{rand(1..50)},#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}\n"
1410+ # # file.write(random_line)
1411+ # # end
1412+ # end
14141413 ####
14151414 totalB = 0
14161415 totalB_s = 0
@@ -1489,10 +1488,10 @@ def generateCountryDatav7()
14891488 end
14901489 countryBudget = tempTotalBudget *countryPercentage /100
14911490 totalB = totalB + countryBudget
1492- File . open ( filename , 'a' ) do |file |
1493- row = "#{ c } ,#{ countryBudget } ,#{ tempTotalBudget } ,#{ element [ 'iati_identifier' ] } \n "
1494- file . write ( row )
1495- end
1491+ # File.open(filename, 'a') do |file|
1492+ # row = "#{c},#{countryBudget},#{tempTotalBudget},#{element['iati_identifier']}\n"
1493+ # file.write(row)
1494+ # end
14961495 #budgetTracker = budgetTracker - countryBudget
14971496 if ( projectDataHash . has_key? ( c ) )
14981497 # if(isNewProgramme)
@@ -1519,6 +1518,14 @@ def generateCountryDatav7()
15191518 end
15201519 end
15211520 end
1521+ if ( projectDataHash . has_key? ( 'SO' ) )
1522+ projectDataHash [ '-99SOM' ] = { }
1523+ projectDataHash [ '-99SOM' ] [ "id" ] = 'SO'
1524+ projectDataHash [ '-99SOM' ] [ "country" ] = projectDataHash [ 'SO' ] [ "country" ]
1525+ projectDataHash [ '-99SOM' ] [ "projects" ] = projectDataHash [ 'SO' ] [ "projects" ]
1526+ projectDataHash [ '-99SOM' ] [ "budget" ] = projectDataHash [ 'SO' ] [ "budget" ]
1527+ projectDataHash [ '-99SOM' ] [ "flag" ] = projectDataHash [ 'SO' ] [ "flag" ]
1528+ end
15221529 finalOutput = Array . new
15231530 finalOutput . push ( projectDataHash . to_s . gsub ( "[" , "" ) . gsub ( "]" , "" ) . gsub ( "=>" , ":" ) . gsub ( "}}, {" , "}," ) )
15241531 finalOutput . push ( projectDataHash )
0 commit comments