In [58]:
from os import listdir
import csv
from os.path import isfile, join

In [59]:
dir_path = "../../../source/total_expenditure_by_select_ministries/"
file_path = "data/total_expenditure_by_select_ministries.csv"
file_name = "total_expenditure_by_select_ministries"

In [60]:
#remove_characters ="!@#$()*%"
with open(file_path, 'r+') as csvfile:
    print csvfile
    
    index_file = open(dir_path + "index.rst", "wb")
    print file_name.title()
    index_file.write(file_name.title().replace("_"," ") + "\n")
    index_file.write("="*len(file_name) + "\n")
    index_file.write("\nContents:\n\n")
    index_file.write(".. toctree::\n\t:maxdepth: 2\n\n")

    reader = csv.DictReader(csvfile)
    for line in reader:
        sub_file = line["index_name"]
        index_file.write("\t" + line["slug_name"] +"\n")
        print line['slug_name'], line["index_name"]
        fo = open(dir_path + line["slug_name"]+".rst", "wb")
        fo.write(line["index_name"]+"\n")
        fo.write("="*(len(line["index_name"])+ 3) + "\n")
        fo.write("\n.. raw:: html\n\n" )
        fo.write("\t" + str("<iframe src='../viz/visualization.html#barchart/"+ file_name +"/"+ line["slug_name"] +"' width='100%', height='500', frameBorder='0'></iframe>"))
        fo.close()
    index_file.close()


<open file 'data/total_expenditure_by_select_ministries.csv', mode 'r+' at 0x7f76dc3d6540>
Total_Expenditure_By_Select_Ministries
ministry_of_culture 1. Ministry of Culture
ministrydept_of_drinking_water_and_sanitation 2. Ministry/Dept. of Drinking Water and Sanitation
ministry_of_health_and_family_welfare_including_ayush 3. Ministry of Health and Family Welfare (including AYUSH)
ministry_of_housing_and_urban_poverty_alleviation 4. Ministry of Housing and Urban Poverty Alleviation
ministry_of_human_resource_development 5. Ministry of Human Resource Development
ministry_of_labour_and_employment 6. Ministry of Labour and Employment
ministry_of_minority_affairs 7. Ministry of Minority Affairs
ministry_of_social_justice_and_empowerment 8. Ministry of Social Justice and Empowerment
ministry_of_tribal_affairs 9. Ministry of Tribal Affairs
dept_of_urban_development 10. Dept. of Urban Development
ministry_of_women_and_child_development 11. Ministry of Women and Child Development
ministry_of_youth_affairs_and_sports 12. Ministry of Youth Affairs and Sports
empowerment_of_persons_with_disabilities 13. Empowerment of Persons with Disabilities
ministry_of_agriculture_cooperation_and_farmers_welfare 14. Ministry of Agriculture, Cooperation and Farmers Welfare
ministry_of_environment_forest_and_climate_change 15. Ministry of Environment, Forest and Climate Change 
ministry_of_rural_development 16. Ministry of Rural Development
ministry_of_consumer_affairs_food_and_public_distribution_food_subsidy 17. Ministry of Consumer Affairs, Food and Public Distribution (Food Subsidy)
total_expenditure_in_select_ministries_1_to_17 Total expenditure in select ministries (1 to 17)
ministry_of_road_transport_and_highways 18. Ministry of Road Transport and Highways
defence 19. Defence
total_expenditure_in_select_ministries_1_to_19 Total expenditure in select ministries (1 to 19)
total_union_government_expenditure Total Union Government Expenditure
total_expenditure_in_ministries_1_to_17_as_share_of_total_union_govt_expenditure_in_perc Total expenditure in ministries (1 to 17) as share of total Union Govt. expenditure (in %)
total_expenditure_in_ministries_1_to_19_as_share_of_total_union_govt_expenditure_in_perc Total expenditure in ministries (1 to 19) as share of total Union Govt. expenditure (in %)
gdp_at_current_market_prices_series GDP at current market prices (2011-12 series)
total_expenditure_in_select_ministries_1_to_17_as_share_of_gdp_in_perc Total expenditure in select ministries (1 to 17) as share of GDP (in %)
total_expenditure_in_select_ministries_1_to_19_as_share_of_gdp_in_perc Total expenditure in select ministries (1 to 19) as share of GDP (in %)

In [41]:



Agriculture

In [ ]: