[{"data":1,"prerenderedAt":2124},["ShallowReactive",2],{"/blog/learn-python-with-pj-part-4-dictionaries-and-files":3,"navigation-en-us":1338,"banner-en-us":1766,"footer-en-us":1776,"blog-post-authors-en-us-PJ Metz":2021,"blog-related-posts-en-us-learn-python-with-pj-part-4-dictionaries-and-files":2037,"blog-promotions-en-us":2060,"next-steps-en-us":2114},{"id":4,"title":5,"authors":6,"body":8,"category":1318,"date":1319,"description":1320,"extension":1321,"externalUrl":1322,"faq":1322,"featured":1323,"heroImage":1324,"meta":1325,"navigation":586,"path":1326,"seo":1327,"slug":1331,"stem":1332,"tags":1333,"template":1336,"updatedDate":1322,"__hash__":1337},"blogPosts/en-us/blog/learn-python-with-pj-part-4-dictionaries-and-files.md","Learn Python with Pj! Part 4 - Dictionaries and Files",[7],"PJ Metz",{"type":9,"value":10,"toc":1310},"minimark",[11,15,44,47,50,55,63,169,180,360,379,390,623,626,752,768,772,775,780,791,844,859,903,907,932,971,975,986,1055,1058,1061,1269,1298,1306],[12,13,14],"p",{},"This is the fourth installment in the Learn Python with Pj! series. Make sure to read:",[16,17,18,26,32,38],"ul",{},[19,20,21],"li",{},[22,23,25],"a",{"href":24},"/blog/learn-python-with-pj-part-1/","Part 1 - Getting started",[19,27,28],{},[22,29,31],{"href":30},"/blog/learn-python-with-pj-part-2/","Part 2 - Lists and loops",[19,33,34],{},[22,35,37],{"href":36},"/blog/learn-python-with-pj-part-3/","Part 3 - Functions and strings",[19,39,40],{},[22,41,43],{"href":42},"/blog/learn-python-with-pj-part-5-building-something-with-the-twitter-api/","Part 5 - Build a hashtag tracker with the Twitter API",[12,45,46],{},"I’ve learned a lot with Python so far, but when I learned dictionaries (sometimes shortened to dicts), I was really excited about what could be done. A dictionary in Python is a series of keys and values stored inside a single object. This is kind of like a super array; one that allows you to connect keys and values together in a single easily accessible source. Creating dictionaries from arrays can actually be very simple, too.",[12,48,49],{},"In this blog, I'll dig into how to create dictionaries and how to read and write files in the code.",[51,52,54],"h2",{"id":53},"dictionaries","Dictionaries",[12,56,57,58,62],{},"Dictionaries in Python are indicated by using curly braces, or as I like to call them, mustaches. ",[59,60,61],"code",{},"{ }"," indicates that the list you’re looking at isn’t a list at all, but a dictionary.",[64,65,70],"pre",{"className":66,"code":67,"language":68,"meta":69,"style":69},"language-python shiki shiki-themes github-light","shows_and _characters = {\n    \"Bojack Horseman\": \"Todd\",\n    \"My Hero Academia\": \"Midoriya\"\n    \"Ozark\": \"Ruth\"\n    \"Arrested Development\": \"Tobias\",\n    \"Derry Girls\": \"Sister Michael\",\n    \"Tuca & Bertie\": \"Bertie\"\n    }\n\n","python","",[59,71,72,88,104,115,126,139,152,163],{"__ignoreMap":69},[73,74,77,81,85],"span",{"class":75,"line":76},"line",1,[73,78,80],{"class":79},"sgsFI","shows_and _characters ",[73,82,84],{"class":83},"sD7c4","=",[73,86,87],{"class":79}," {\n",[73,89,91,95,98,101],{"class":75,"line":90},2,[73,92,94],{"class":93},"sYBdl","    \"Bojack Horseman\"",[73,96,97],{"class":79},": ",[73,99,100],{"class":93},"\"Todd\"",[73,102,103],{"class":79},",\n",[73,105,107,110,112],{"class":75,"line":106},3,[73,108,109],{"class":93},"    \"My Hero Academia\"",[73,111,97],{"class":79},[73,113,114],{"class":93},"\"Midoriya\"\n",[73,116,118,121,123],{"class":75,"line":117},4,[73,119,120],{"class":93},"    \"Ozark\"",[73,122,97],{"class":79},[73,124,125],{"class":93},"\"Ruth\"\n",[73,127,129,132,134,137],{"class":75,"line":128},5,[73,130,131],{"class":93},"    \"Arrested Development\"",[73,133,97],{"class":79},[73,135,136],{"class":93},"\"Tobias\"",[73,138,103],{"class":79},[73,140,142,145,147,150],{"class":75,"line":141},6,[73,143,144],{"class":93},"    \"Derry Girls\"",[73,146,97],{"class":79},[73,148,149],{"class":93},"\"Sister Michael\"",[73,151,103],{"class":79},[73,153,155,158,160],{"class":75,"line":154},7,[73,156,157],{"class":93},"    \"Tuca & Bertie\"",[73,159,97],{"class":79},[73,161,162],{"class":93},"\"Bertie\"\n",[73,164,166],{"class":75,"line":165},8,[73,167,168],{"class":79},"    }\n",[12,170,171,172,175,176,179],{},"This is a dictionary of my favorite TV shows and my favorite characters in that show. In this example, the key is on the left and the value is on the right. To access dictionaries, you use a similar call like you would for a list, except instead of an element number, you would put the key. ",[59,173,174],{},"print(shows_and_characters[“Ozark”])"," would print ",[59,177,178],{},"Ruth"," to the console. Additionally, both the key and value in this example are strings, but that’s not a requirement. Keys can be any immutable type, like strings, ints, floats, and tuples. Values don’t have this same restriction, therefore values can be a nested dictionary or a list, in addition to the types mentioned for keys. For instance, the following dictionary is a valid dictionary.",[64,181,183],{"className":66,"code":182,"language":68,"meta":69,"style":69},"shows_with_lists = {\n    \"Bojack Horseman\": [\"Todd\", \"Princess Carolyn\", \"Judah\", \"Diane\"],\n    \"My Hero Academia\": [\"Midoriya\", \"Shoto\", \"All Might\", \"Bakugo\", \"Kirishima\"],\n    \"Ozark\": [\"Ruth\", \"Jonah\", \"Wyatt\"],\n    \"Arrested Development\": [\"Tobias\", \"Gob\", \"Anne\", \"Maeby\"],\n    \"Derry Girls\": [\"Sister Michael\", \"Orla\", \"Erin\", \"Claire\", \"James\"],\n    \"Tuca & Bertie\": [\"Bertie\", \"Speckle\", \"Tuca\", \"Dakota\"]\n    }\n\n",[59,184,185,194,222,253,274,299,329,356],{"__ignoreMap":69},[73,186,187,190,192],{"class":75,"line":76},[73,188,189],{"class":79},"shows_with_lists ",[73,191,84],{"class":83},[73,193,87],{"class":79},[73,195,196,198,201,203,206,209,211,214,216,219],{"class":75,"line":90},[73,197,94],{"class":93},[73,199,200],{"class":79},": [",[73,202,100],{"class":93},[73,204,205],{"class":79},", ",[73,207,208],{"class":93},"\"Princess Carolyn\"",[73,210,205],{"class":79},[73,212,213],{"class":93},"\"Judah\"",[73,215,205],{"class":79},[73,217,218],{"class":93},"\"Diane\"",[73,220,221],{"class":79},"],\n",[73,223,224,226,228,231,233,236,238,241,243,246,248,251],{"class":75,"line":106},[73,225,109],{"class":93},[73,227,200],{"class":79},[73,229,230],{"class":93},"\"Midoriya\"",[73,232,205],{"class":79},[73,234,235],{"class":93},"\"Shoto\"",[73,237,205],{"class":79},[73,239,240],{"class":93},"\"All Might\"",[73,242,205],{"class":79},[73,244,245],{"class":93},"\"Bakugo\"",[73,247,205],{"class":79},[73,249,250],{"class":93},"\"Kirishima\"",[73,252,221],{"class":79},[73,254,255,257,259,262,264,267,269,272],{"class":75,"line":117},[73,256,120],{"class":93},[73,258,200],{"class":79},[73,260,261],{"class":93},"\"Ruth\"",[73,263,205],{"class":79},[73,265,266],{"class":93},"\"Jonah\"",[73,268,205],{"class":79},[73,270,271],{"class":93},"\"Wyatt\"",[73,273,221],{"class":79},[73,275,276,278,280,282,284,287,289,292,294,297],{"class":75,"line":128},[73,277,131],{"class":93},[73,279,200],{"class":79},[73,281,136],{"class":93},[73,283,205],{"class":79},[73,285,286],{"class":93},"\"Gob\"",[73,288,205],{"class":79},[73,290,291],{"class":93},"\"Anne\"",[73,293,205],{"class":79},[73,295,296],{"class":93},"\"Maeby\"",[73,298,221],{"class":79},[73,300,301,303,305,307,309,312,314,317,319,322,324,327],{"class":75,"line":141},[73,302,144],{"class":93},[73,304,200],{"class":79},[73,306,149],{"class":93},[73,308,205],{"class":79},[73,310,311],{"class":93},"\"Orla\"",[73,313,205],{"class":79},[73,315,316],{"class":93},"\"Erin\"",[73,318,205],{"class":79},[73,320,321],{"class":93},"\"Claire\"",[73,323,205],{"class":79},[73,325,326],{"class":93},"\"James\"",[73,328,221],{"class":79},[73,330,331,333,335,338,340,343,345,348,350,353],{"class":75,"line":154},[73,332,157],{"class":93},[73,334,200],{"class":79},[73,336,337],{"class":93},"\"Bertie\"",[73,339,205],{"class":79},[73,341,342],{"class":93},"\"Speckle\"",[73,344,205],{"class":79},[73,346,347],{"class":93},"\"Tuca\"",[73,349,205],{"class":79},[73,351,352],{"class":93},"\"Dakota\"",[73,354,355],{"class":79},"]\n",[73,357,358],{"class":75,"line":165},[73,359,168],{"class":79},[12,361,362,363,366,367,370,371,374,375,378],{},"In this example, each value is a list. So if we tried to print the value for the key ",[59,364,365],{},"”Derry Girls”",", we would see ",[59,368,369],{},"[“Sister Michael”, “Orla”, “Erin”, “Claire”, “James”]"," printed to the console. However, if we wanted the last element in the value list, we’d write ",[59,372,373],{},"shows_with_lists[“Derry Girls”] [-1]",". This would print the last element in the list, which in this case is ",[59,376,377],{},"James",".",[12,380,381,382,385,386,389],{},"Dictionaries can be written manually, or, if you have two lists, you can combine the ",[59,383,384],{},"dict()"," and ",[59,387,388],{},"zip()"," methods to make the lists into a dictionary.",[64,391,393],{"className":66,"code":392,"language":68,"meta":69,"style":69},"list_of_shows = [\"Bojack Horseman\",\n                 \"My Hero Academia\",\n                 \"Ozark\",\n                 \"Arrested Development\",\n                 \"Derry Girls\",\n                 \"Tuca & Bertie\"]\nlist_of_characters = [[\"Todd\", \"Princess Carolyn\", \"Judah\", \"Diane\"],\n                      [\"Midoriya\", \"Shoto\", \"All Might\", \"Bakugo\", \"Kirishima\"],\n                      [\"Ruth\", \"Jonah\", \"Wyatt\"],\n                      [\"Tobias\", \"Gob\", \"Anne\", \"Maeby\"],\n                      [\"Sister Michael\", \"Orla\", \"Erin\", \"Claire\", \"James\"],\n                      [\"Bertie\", \"Speckle\", \"Tuca\", \"Dakota\"]]\n\ncombined_shows_characters = dict(zip(list_of_shows, list_of_characters))\n\nprint(combined_shows_characters)\n",[59,394,395,410,417,424,431,438,445,471,496,513,534,559,581,588,609,614],{"__ignoreMap":69},[73,396,397,400,402,405,408],{"class":75,"line":76},[73,398,399],{"class":79},"list_of_shows ",[73,401,84],{"class":83},[73,403,404],{"class":79}," [",[73,406,407],{"class":93},"\"Bojack Horseman\"",[73,409,103],{"class":79},[73,411,412,415],{"class":75,"line":90},[73,413,414],{"class":93},"                 \"My Hero Academia\"",[73,416,103],{"class":79},[73,418,419,422],{"class":75,"line":106},[73,420,421],{"class":93},"                 \"Ozark\"",[73,423,103],{"class":79},[73,425,426,429],{"class":75,"line":117},[73,427,428],{"class":93},"                 \"Arrested Development\"",[73,430,103],{"class":79},[73,432,433,436],{"class":75,"line":128},[73,434,435],{"class":93},"                 \"Derry Girls\"",[73,437,103],{"class":79},[73,439,440,443],{"class":75,"line":141},[73,441,442],{"class":93},"                 \"Tuca & Bertie\"",[73,444,355],{"class":79},[73,446,447,450,452,455,457,459,461,463,465,467,469],{"class":75,"line":154},[73,448,449],{"class":79},"list_of_characters ",[73,451,84],{"class":83},[73,453,454],{"class":79}," [[",[73,456,100],{"class":93},[73,458,205],{"class":79},[73,460,208],{"class":93},[73,462,205],{"class":79},[73,464,213],{"class":93},[73,466,205],{"class":79},[73,468,218],{"class":93},[73,470,221],{"class":79},[73,472,473,476,478,480,482,484,486,488,490,492,494],{"class":75,"line":165},[73,474,475],{"class":79},"                      [",[73,477,230],{"class":93},[73,479,205],{"class":79},[73,481,235],{"class":93},[73,483,205],{"class":79},[73,485,240],{"class":93},[73,487,205],{"class":79},[73,489,245],{"class":93},[73,491,205],{"class":79},[73,493,250],{"class":93},[73,495,221],{"class":79},[73,497,499,501,503,505,507,509,511],{"class":75,"line":498},9,[73,500,475],{"class":79},[73,502,261],{"class":93},[73,504,205],{"class":79},[73,506,266],{"class":93},[73,508,205],{"class":79},[73,510,271],{"class":93},[73,512,221],{"class":79},[73,514,516,518,520,522,524,526,528,530,532],{"class":75,"line":515},10,[73,517,475],{"class":79},[73,519,136],{"class":93},[73,521,205],{"class":79},[73,523,286],{"class":93},[73,525,205],{"class":79},[73,527,291],{"class":93},[73,529,205],{"class":79},[73,531,296],{"class":93},[73,533,221],{"class":79},[73,535,537,539,541,543,545,547,549,551,553,555,557],{"class":75,"line":536},11,[73,538,475],{"class":79},[73,540,149],{"class":93},[73,542,205],{"class":79},[73,544,311],{"class":93},[73,546,205],{"class":79},[73,548,316],{"class":93},[73,550,205],{"class":79},[73,552,321],{"class":93},[73,554,205],{"class":79},[73,556,326],{"class":93},[73,558,221],{"class":79},[73,560,562,564,566,568,570,572,574,576,578],{"class":75,"line":561},12,[73,563,475],{"class":79},[73,565,337],{"class":93},[73,567,205],{"class":79},[73,569,342],{"class":93},[73,571,205],{"class":79},[73,573,347],{"class":93},[73,575,205],{"class":79},[73,577,352],{"class":93},[73,579,580],{"class":79},"]]\n",[73,582,584],{"class":75,"line":583},13,[73,585,587],{"emptyLinePlaceholder":586},true,"\n",[73,589,591,594,596,600,603,606],{"class":75,"line":590},14,[73,592,593],{"class":79},"combined_shows_characters ",[73,595,84],{"class":83},[73,597,599],{"class":598},"sYu0t"," dict",[73,601,602],{"class":79},"(",[73,604,605],{"class":598},"zip",[73,607,608],{"class":79},"(list_of_shows, list_of_characters))\n",[73,610,612],{"class":75,"line":611},15,[73,613,587],{"emptyLinePlaceholder":586},[73,615,617,620],{"class":75,"line":616},16,[73,618,619],{"class":598},"print",[73,621,622],{"class":79},"(combined_shows_characters)\n",[12,624,625],{},"This is one way to create a dictionary. Another is called Dictionary Comprehension. This one is a little more work, but can be used in a variety of different ways, including using a bit of logic on a single list to generate a dictionary using that original list. Here’s how with two examples: one based on the above lists, and one with a single list and some logic.",[64,627,629],{"className":66,"code":628,"language":68,"meta":69,"style":69},"import math\n\n#This is doing the same work as the above example, but using Dict Comprehension instead. \ncomprehension_shows_characters = { shows:characters for shows, characters in zip(list_of_shows, list_of_characters)  }\n\nhip_to_be_square = [4, 9, 16, 25, 36, 49]\n\nno_longer_hip_to_be_square = { key:math.sqrt(key) for key in hip_to_be_square }\n\nprint(no_longer_hip_to_be_square)\n",[59,630,631,639,643,649,674,678,717,721,741,745],{"__ignoreMap":69},[73,632,633,636],{"class":75,"line":76},[73,634,635],{"class":83},"import",[73,637,638],{"class":79}," math\n",[73,640,641],{"class":75,"line":90},[73,642,587],{"emptyLinePlaceholder":586},[73,644,645],{"class":75,"line":106},[73,646,648],{"class":647},"sAwPA","#This is doing the same work as the above example, but using Dict Comprehension instead. \n",[73,650,651,654,656,659,662,665,668,671],{"class":75,"line":117},[73,652,653],{"class":79},"comprehension_shows_characters ",[73,655,84],{"class":83},[73,657,658],{"class":79}," { shows:characters ",[73,660,661],{"class":83},"for",[73,663,664],{"class":79}," shows, characters ",[73,666,667],{"class":83},"in",[73,669,670],{"class":598}," zip",[73,672,673],{"class":79},"(list_of_shows, list_of_characters)  }\n",[73,675,676],{"class":75,"line":128},[73,677,587],{"emptyLinePlaceholder":586},[73,679,680,683,685,687,690,692,695,697,700,702,705,707,710,712,715],{"class":75,"line":141},[73,681,682],{"class":79},"hip_to_be_square ",[73,684,84],{"class":83},[73,686,404],{"class":79},[73,688,689],{"class":598},"4",[73,691,205],{"class":79},[73,693,694],{"class":598},"9",[73,696,205],{"class":79},[73,698,699],{"class":598},"16",[73,701,205],{"class":79},[73,703,704],{"class":598},"25",[73,706,205],{"class":79},[73,708,709],{"class":598},"36",[73,711,205],{"class":79},[73,713,714],{"class":598},"49",[73,716,355],{"class":79},[73,718,719],{"class":75,"line":154},[73,720,587],{"emptyLinePlaceholder":586},[73,722,723,726,728,731,733,736,738],{"class":75,"line":165},[73,724,725],{"class":79},"no_longer_hip_to_be_square ",[73,727,84],{"class":83},[73,729,730],{"class":79}," { key:math.sqrt(key) ",[73,732,661],{"class":83},[73,734,735],{"class":79}," key ",[73,737,667],{"class":83},[73,739,740],{"class":79}," hip_to_be_square }\n",[73,742,743],{"class":75,"line":498},[73,744,587],{"emptyLinePlaceholder":586},[73,746,747,749],{"class":75,"line":515},[73,748,619],{"class":598},[73,750,751],{"class":79},"(no_longer_hip_to_be_square)\n",[12,753,754,755,758,759,762,763,378],{},"In the ",[59,756,757],{},"no_longer_hip_to_be_square"," dictionary, the key is found in the ",[59,760,761],{},"hip_to_be_square"," list. The value for each key is its own square root, brought in with the import math function. There are plenty more useful methods for dealing with dictionaries ",[22,764,767],{"href":765,"rel":766},"https://realpython.com/python-dicts/",[],"here",[51,769,771],{"id":770},"reading-and-writing-files","Reading and writing files",[12,773,774],{},"This one is a pretty cool part of Python: reading and writing other files right in the code. With Python, you’re able to take the contents of certain types of files and use it in your code, or even create a new file based on some input. This is useful for data handling and can be used with a  variety of file types. The two I’ll be covering here are .csv and .txt.",[776,777,779],"h3",{"id":778},"reading-from-a-file","Reading from a file",[12,781,782,783,786,787,790],{},"Imagine a .txt file named ",[59,784,785],{},"best-ever.txt"," containing the line ",[59,788,789],{},"My favorite tv show is Derry Girls",". We can use Python to take that line and turn it into a variable. Running the following code would print the contents of the .txt file to the terminal.",[64,792,794],{"className":66,"code":793,"language":68,"meta":69,"style":69},"with open(\"best-ever.txt\") as text_file:\n  text_data = text_file.read()\n\n#This will print the contents of the .txt file. \nprint(text_data)\n",[59,795,796,818,828,832,837],{"__ignoreMap":69},[73,797,798,801,804,806,809,812,815],{"class":75,"line":76},[73,799,800],{"class":83},"with",[73,802,803],{"class":598}," open",[73,805,602],{"class":79},[73,807,808],{"class":93},"\"best-ever.txt\"",[73,810,811],{"class":79},") ",[73,813,814],{"class":83},"as",[73,816,817],{"class":79}," text_file:\n",[73,819,820,823,825],{"class":75,"line":90},[73,821,822],{"class":79},"  text_data ",[73,824,84],{"class":83},[73,826,827],{"class":79}," text_file.read()\n",[73,829,830],{"class":75,"line":106},[73,831,587],{"emptyLinePlaceholder":586},[73,833,834],{"class":75,"line":117},[73,835,836],{"class":647},"#This will print the contents of the .txt file. \n",[73,838,839,841],{"class":75,"line":128},[73,840,619],{"class":598},[73,842,843],{"class":79},"(text_data)\n",[12,845,846,847,850,851,854,855,858],{},"By using ",[59,848,849],{},"with open(NAME OF FILE) as VARIABLE_NAME:",", we can examine the contents of files as a single string. If the document has multiple lines, you can even separate those by iterating over them by using a for loop and the ",[59,852,853],{},".readlines()"," method. Using an imaginary .txt document called ",[59,856,857],{},"buncha-lines"," we could use the following to print out each line individually.",[64,860,862],{"className":66,"code":861,"language":68,"meta":69,"style":69},"with open(\"buncha-lines.txt\") as lines_doc:\n  for line in lines_doc.readlines():\n    print(line)\n\n",[59,863,864,882,895],{"__ignoreMap":69},[73,865,866,868,870,872,875,877,879],{"class":75,"line":76},[73,867,800],{"class":83},[73,869,803],{"class":598},[73,871,602],{"class":79},[73,873,874],{"class":93},"\"buncha-lines.txt\"",[73,876,811],{"class":79},[73,878,814],{"class":83},[73,880,881],{"class":79}," lines_doc:\n",[73,883,884,887,890,892],{"class":75,"line":90},[73,885,886],{"class":83},"  for",[73,888,889],{"class":79}," line ",[73,891,667],{"class":83},[73,893,894],{"class":79}," lines_doc.readlines():\n",[73,896,897,900],{"class":75,"line":106},[73,898,899],{"class":598},"    print",[73,901,902],{"class":79},"(line)\n",[776,904,906],{"id":905},"writing-a-new-file","Writing a new file",[12,908,909,910,913,914,917,918,920,921,924,925,928,929,378],{},"Creating a new file is also easy with Python. The ",[59,911,912],{},"open()"," function can take an additional argument in order to create a new file. In fact, there’s a default argument that’s been being passed each time without us knowing! ",[59,915,916],{},"r"," is the default argument for ",[59,919,912],{}," and puts it in read mode. To turn on write mode, pass in a ",[59,922,923],{},"w"," as the second argument. The following code will write a brand-new file called ",[59,926,927],{},"best_tv_character.txt"," with the contents ",[59,930,931],{},"Peggy Olson from Mad Men",[64,933,935],{"className":66,"code":934,"language":68,"meta":69,"style":69},"with open(\"best_tv_character.txt\", \"w\") as best_character:\n  best_character.write(\"Peggy Olson from Mad Men\")\n\n",[59,936,937,960],{"__ignoreMap":69},[73,938,939,941,943,945,948,950,953,955,957],{"class":75,"line":76},[73,940,800],{"class":83},[73,942,803],{"class":598},[73,944,602],{"class":79},[73,946,947],{"class":93},"\"best_tv_character.txt\"",[73,949,205],{"class":79},[73,951,952],{"class":93},"\"w\"",[73,954,811],{"class":79},[73,956,814],{"class":83},[73,958,959],{"class":79}," best_character:\n",[73,961,962,965,968],{"class":75,"line":90},[73,963,964],{"class":79},"  best_character.write(",[73,966,967],{"class":93},"\"Peggy Olson from Mad Men\"",[73,969,970],{"class":79},")\n",[776,972,974],{"id":973},"working-with-csv-files","Working with .csv files",[12,976,977,978,981,982,985],{},"You can read a .csv file with Python by using ",[59,979,980],{},"import csv"," at the beginning of the file, and then using some of its built-in methods in the code. However, even though .csv files are plain text, treating a .csv file the same as you treat .txt files can lead to difficult to read outputs; after all, the point of a spreadsheet is to table information. Without that table, the output can be chaotic. A way around this is to use the ",[59,983,984],{},"dictreader()"," method. This method allows you to map the information in each row to a dictionary with field names you can create. The default field names are collected from the first row of the .csv if no field names are given. Imagine a .csv file with columns labeled, “Network”, “Show name”, “Seasons”. Maybe we just want to print the number of seasons from this .csv.",[64,987,989],{"className":66,"code":988,"language":68,"meta":69,"style":69},"import csv \n\nwith open(\"shows.csv\") as shows_csv:\n  shows_dict = csv.DictReader(shows_csv)\n  for row in shows_dict:\n    print(row[\"Seasons\"])\n\n",[59,990,991,998,1002,1020,1030,1042],{"__ignoreMap":69},[73,992,993,995],{"class":75,"line":76},[73,994,635],{"class":83},[73,996,997],{"class":79}," csv \n",[73,999,1000],{"class":75,"line":90},[73,1001,587],{"emptyLinePlaceholder":586},[73,1003,1004,1006,1008,1010,1013,1015,1017],{"class":75,"line":106},[73,1005,800],{"class":83},[73,1007,803],{"class":598},[73,1009,602],{"class":79},[73,1011,1012],{"class":93},"\"shows.csv\"",[73,1014,811],{"class":79},[73,1016,814],{"class":83},[73,1018,1019],{"class":79}," shows_csv:\n",[73,1021,1022,1025,1027],{"class":75,"line":117},[73,1023,1024],{"class":79},"  shows_dict ",[73,1026,84],{"class":83},[73,1028,1029],{"class":79}," csv.DictReader(shows_csv)\n",[73,1031,1032,1034,1037,1039],{"class":75,"line":128},[73,1033,886],{"class":83},[73,1035,1036],{"class":79}," row ",[73,1038,667],{"class":83},[73,1040,1041],{"class":79}," shows_dict:\n",[73,1043,1044,1046,1049,1052],{"class":75,"line":141},[73,1045,899],{"class":598},[73,1047,1048],{"class":79},"(row[",[73,1050,1051],{"class":93},"\"Seasons\"",[73,1053,1054],{"class":79},"])\n",[12,1056,1057],{},"This would print to the console, on a new line, the number of seasons for each row that exists in the .csv.",[12,1059,1060],{},"Just like with .txt files, you can also create .csv files with Python. It’s a bit more complicated since you need to define the headers, or column names, but it is still a quick process. This can be used to take lists and turn them into .csv files. Let’s check out the following example:",[64,1062,1064],{"className":66,"code":1063,"language":68,"meta":69,"style":69},"import csv\n\nworking_list = [{\"Network\": \"Netflix\", \"Show Name\":\"Bojack Horseman\", \"Seasons\":6}, {\"Network\":\"Channel 4\",\"Show Name\":\"Derry Girls\", \"Seasons\": 3}, {\"Network\":\"HBO Max\", \"Show Name\":\"Our Flag Means Death\", \"Seasons\": 1}]\n\n\nwith open(\"shows.csv\", \"w\") as shows_csv:\n    fields = [\"Network\", \"Show Name\", \"Seasons\"]\n    shows_w = csv.DictWriter(shows_csv, fieldnames = fields)\n\n    shows_w.writeheader()\n    for item in working_list:\n        shows_w.writerow(item)\n\n",[59,1065,1066,1073,1077,1173,1177,1181,1201,1222,1242,1246,1251,1264],{"__ignoreMap":69},[73,1067,1068,1070],{"class":75,"line":76},[73,1069,635],{"class":83},[73,1071,1072],{"class":79}," csv\n",[73,1074,1075],{"class":75,"line":90},[73,1076,587],{"emptyLinePlaceholder":586},[73,1078,1079,1082,1084,1087,1090,1092,1095,1097,1100,1103,1105,1107,1109,1111,1114,1117,1119,1121,1124,1127,1129,1131,1134,1136,1138,1140,1143,1145,1147,1149,1152,1154,1156,1158,1161,1163,1165,1167,1170],{"class":75,"line":106},[73,1080,1081],{"class":79},"working_list ",[73,1083,84],{"class":83},[73,1085,1086],{"class":79}," [{",[73,1088,1089],{"class":93},"\"Network\"",[73,1091,97],{"class":79},[73,1093,1094],{"class":93},"\"Netflix\"",[73,1096,205],{"class":79},[73,1098,1099],{"class":93},"\"Show Name\"",[73,1101,1102],{"class":79},":",[73,1104,407],{"class":93},[73,1106,205],{"class":79},[73,1108,1051],{"class":93},[73,1110,1102],{"class":79},[73,1112,1113],{"class":598},"6",[73,1115,1116],{"class":79},"}, {",[73,1118,1089],{"class":93},[73,1120,1102],{"class":79},[73,1122,1123],{"class":93},"\"Channel 4\"",[73,1125,1126],{"class":79},",",[73,1128,1099],{"class":93},[73,1130,1102],{"class":79},[73,1132,1133],{"class":93},"\"Derry Girls\"",[73,1135,205],{"class":79},[73,1137,1051],{"class":93},[73,1139,97],{"class":79},[73,1141,1142],{"class":598},"3",[73,1144,1116],{"class":79},[73,1146,1089],{"class":93},[73,1148,1102],{"class":79},[73,1150,1151],{"class":93},"\"HBO Max\"",[73,1153,205],{"class":79},[73,1155,1099],{"class":93},[73,1157,1102],{"class":79},[73,1159,1160],{"class":93},"\"Our Flag Means Death\"",[73,1162,205],{"class":79},[73,1164,1051],{"class":93},[73,1166,97],{"class":79},[73,1168,1169],{"class":598},"1",[73,1171,1172],{"class":79},"}]\n",[73,1174,1175],{"class":75,"line":117},[73,1176,587],{"emptyLinePlaceholder":586},[73,1178,1179],{"class":75,"line":128},[73,1180,587],{"emptyLinePlaceholder":586},[73,1182,1183,1185,1187,1189,1191,1193,1195,1197,1199],{"class":75,"line":141},[73,1184,800],{"class":83},[73,1186,803],{"class":598},[73,1188,602],{"class":79},[73,1190,1012],{"class":93},[73,1192,205],{"class":79},[73,1194,952],{"class":93},[73,1196,811],{"class":79},[73,1198,814],{"class":83},[73,1200,1019],{"class":79},[73,1202,1203,1206,1208,1210,1212,1214,1216,1218,1220],{"class":75,"line":154},[73,1204,1205],{"class":79},"    fields ",[73,1207,84],{"class":83},[73,1209,404],{"class":79},[73,1211,1089],{"class":93},[73,1213,205],{"class":79},[73,1215,1099],{"class":93},[73,1217,205],{"class":79},[73,1219,1051],{"class":93},[73,1221,355],{"class":79},[73,1223,1224,1227,1229,1232,1236,1239],{"class":75,"line":165},[73,1225,1226],{"class":79},"    shows_w ",[73,1228,84],{"class":83},[73,1230,1231],{"class":79}," csv.DictWriter(shows_csv, ",[73,1233,1235],{"class":1234},"sqxcx","fieldnames",[73,1237,1238],{"class":83}," =",[73,1240,1241],{"class":79}," fields)\n",[73,1243,1244],{"class":75,"line":498},[73,1245,587],{"emptyLinePlaceholder":586},[73,1247,1248],{"class":75,"line":515},[73,1249,1250],{"class":79},"    shows_w.writeheader()\n",[73,1252,1253,1256,1259,1261],{"class":75,"line":536},[73,1254,1255],{"class":83},"    for",[73,1257,1258],{"class":79}," item ",[73,1260,667],{"class":83},[73,1262,1263],{"class":79}," working_list:\n",[73,1265,1266],{"class":75,"line":561},[73,1267,1268],{"class":79},"        shows_w.writerow(item)\n",[12,1270,1271,1272,1275,1276,1278,1279,1282,1283,1285,1286,1289,1290,1293,1294,1297],{},"This previous code block creates a brand-new csv file by using the ",[59,1273,1274],{},"”w”"," parameter in ",[59,1277,912],{},". We manually name the fields in the order they appear in a separate list, then pass that list into the ",[59,1280,1281],{},"DictWriter"," parameter ",[59,1284,1235],{},". Finally, we use the ",[59,1287,1288],{},"writeheader()"," and a for loop with the ",[59,1291,1292],{},"writerow()"," methods to create a header row and to iterate over the ",[59,1295,1296],{},"working_list"," and turn each entry into a row in the .csv.",[12,1299,1300,1301,378],{},"These are only a few ways to work with .csv and .txt files; Python is very versatile and more information ",[22,1302,1305],{"href":1303,"rel":1304},"https://realpython.com/working-with-files-in-python/",[],"can be found here",[1307,1308,1309],"style",{},"html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}html pre.shiki code .sD7c4, html code.shiki .sD7c4{--shiki-default:#D73A49}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html pre.shiki code .sqxcx, html code.shiki .sqxcx{--shiki-default:#E36209}",{"title":69,"searchDepth":90,"depth":90,"links":1311},[1312,1313],{"id":53,"depth":90,"text":54},{"id":770,"depth":90,"text":771,"children":1314},[1315,1316,1317],{"id":778,"depth":106,"text":779},{"id":905,"depth":106,"text":906},{"id":973,"depth":106,"text":974},"careers","2022-05-05","Our education evangelist Pj Metz continues his journey to learn how to code in Python.","md",null,false,"https://res.cloudinary.com/about-gitlab-com/image/upload/v1749664962/Blog/Hero%20Images/python.jpg",{},"/en-us/blog/learn-python-with-pj-part-4-dictionaries-and-files",{"title":5,"description":1320,"ogTitle":5,"ogDescription":1320,"noIndex":1323,"ogImage":1324,"ogUrl":1328,"ogSiteName":1329,"ogType":1330,"canonicalUrls":1328},"https://about.gitlab.com/blog/learn-python-with-pj-part-4-dictionaries-and-files","https://about.gitlab.com","article","learn-python-with-pj-part-4-dictionaries-and-files","en-us/blog/learn-python-with-pj-part-4-dictionaries-and-files",[1318,1334,1335],"tutorial","growth","BlogPost","428dEUuR5MBWa0FqE9VkI4jjNMu6tdjIbUaA1sgkWCY",{"logo":1339,"freeTrial":1344,"sales":1349,"login":1354,"items":1359,"search":1686,"minimal":1717,"duo":1736,"switchNav":1745,"pricingDeployment":1756},{"config":1340},{"href":1341,"dataGaName":1342,"dataGaLocation":1343},"/","gitlab logo","header",{"text":1345,"config":1346},"Get free trial",{"href":1347,"dataGaName":1348,"dataGaLocation":1343},"https://gitlab.com/-/trial_registrations/new?glm_source=about.gitlab.com&glm_content=default-saas-trial/","free trial",{"text":1350,"config":1351},"Request a demo",{"href":1352,"dataGaName":1353,"dataGaLocation":1343},"/sales/?contact-topic=request-demo","sales",{"text":1355,"config":1356},"Sign in",{"href":1357,"dataGaName":1358,"dataGaLocation":1343},"https://gitlab.com/users/sign_in/","sign in",[1360,1389,1489,1494,1608,1664],{"text":1361,"config":1362,"menu":1364},"Platform",{"dataNavLevelOne":1363},"platform",{"type":1365,"columns":1366},"cards",[1367,1373,1381],{"title":1361,"description":1368,"link":1369},"The intelligent orchestration platform for DevSecOps",{"text":1370,"config":1371},"Explore our Platform",{"href":1372,"dataGaName":1363,"dataGaLocation":1343},"/platform/",{"title":1374,"description":1375,"link":1376},"GitLab Duo Agent Platform","Agentic AI for the entire software lifecycle",{"text":1377,"config":1378},"Meet GitLab Duo",{"href":1379,"dataGaName":1380,"dataGaLocation":1343},"/gitlab-duo-agent-platform/","gitlab duo agent platform",{"title":1382,"description":1383,"link":1384},"Why GitLab","See the top reasons enterprises choose GitLab",{"text":1385,"config":1386},"Learn more",{"href":1387,"dataGaName":1388,"dataGaLocation":1343},"/why-gitlab/","why gitlab",{"text":1390,"left":586,"config":1391,"menu":1393},"Product",{"dataNavLevelOne":1392},"solutions",{"type":1394,"link":1395,"columns":1399,"feature":1468},"lists",{"text":1396,"config":1397},"View all Solutions",{"href":1398,"dataGaName":1392,"dataGaLocation":1343},"/solutions/",[1400,1424,1447],{"title":1401,"description":1402,"link":1403,"items":1408},"Automation","CI/CD and automation to accelerate deployment",{"config":1404},{"icon":1405,"href":1406,"dataGaName":1407,"dataGaLocation":1343},"AutomatedCodeAlt","/solutions/delivery-automation/","automated software delivery",[1409,1413,1416,1420],{"text":1410,"config":1411},"CI/CD",{"href":1412,"dataGaLocation":1343,"dataGaName":1410},"/solutions/continuous-integration/",{"text":1374,"config":1414},{"href":1379,"dataGaLocation":1343,"dataGaName":1415},"gitlab duo agent platform - product menu",{"text":1417,"config":1418},"Source Code Management",{"href":1419,"dataGaLocation":1343,"dataGaName":1417},"/solutions/source-code-management/",{"text":1421,"config":1422},"Automated Software Delivery",{"href":1406,"dataGaLocation":1343,"dataGaName":1423},"Automated software delivery",{"title":1425,"description":1426,"link":1427,"items":1432},"Security","Deliver code faster without compromising security",{"config":1428},{"href":1429,"dataGaName":1430,"dataGaLocation":1343,"icon":1431},"/solutions/application-security-testing/","security and compliance","ShieldCheckLight",[1433,1437,1442],{"text":1434,"config":1435},"Application Security Testing",{"href":1429,"dataGaName":1436,"dataGaLocation":1343},"Application security testing",{"text":1438,"config":1439},"Software Supply Chain Security",{"href":1440,"dataGaLocation":1343,"dataGaName":1441},"/solutions/supply-chain/","Software supply chain security",{"text":1443,"config":1444},"Software Compliance",{"href":1445,"dataGaName":1446,"dataGaLocation":1343},"/solutions/software-compliance/","software compliance",{"title":1448,"link":1449,"items":1454},"Measurement",{"config":1450},{"icon":1451,"href":1452,"dataGaName":1453,"dataGaLocation":1343},"DigitalTransformation","/solutions/visibility-measurement/","visibility and measurement",[1455,1459,1463],{"text":1456,"config":1457},"Visibility & Measurement",{"href":1452,"dataGaLocation":1343,"dataGaName":1458},"Visibility and Measurement",{"text":1460,"config":1461},"Value Stream Management",{"href":1462,"dataGaLocation":1343,"dataGaName":1460},"/solutions/value-stream-management/",{"text":1464,"config":1465},"Analytics & Insights",{"href":1466,"dataGaLocation":1343,"dataGaName":1467},"/solutions/analytics-and-insights/","Analytics and insights",{"title":1469,"type":1394,"items":1470},"GitLab for",[1471,1477,1483],{"text":1472,"config":1473},"Enterprise",{"icon":1474,"href":1475,"dataGaLocation":1343,"dataGaName":1476},"Building","/enterprise/","enterprise",{"text":1478,"config":1479},"Small Business",{"icon":1480,"href":1481,"dataGaLocation":1343,"dataGaName":1482},"Work","/small-business/","small business",{"text":1484,"config":1485},"Public Sector",{"icon":1486,"href":1487,"dataGaLocation":1343,"dataGaName":1488},"Organization","/solutions/public-sector/","public sector",{"text":1490,"config":1491},"Pricing",{"href":1492,"dataGaName":1493,"dataGaLocation":1343,"dataNavLevelOne":1493},"/pricing/","pricing",{"text":1495,"config":1496,"menu":1498},"Resources",{"dataNavLevelOne":1497},"resources",{"type":1394,"link":1499,"columns":1503,"feature":1597},{"text":1500,"config":1501},"View all resources",{"href":1502,"dataGaName":1497,"dataGaLocation":1343},"/resources/",[1504,1537,1564],{"title":1505,"items":1506},"Getting started",[1507,1512,1517,1522,1527,1532],{"text":1508,"config":1509},"Install",{"href":1510,"dataGaName":1511,"dataGaLocation":1343},"/install/","install",{"text":1513,"config":1514},"Quick start guides",{"href":1515,"dataGaName":1516,"dataGaLocation":1343},"/get-started/","quick setup checklists",{"text":1518,"config":1519},"Learn",{"href":1520,"dataGaLocation":1343,"dataGaName":1521},"https://university.gitlab.com/","learn",{"text":1523,"config":1524},"Product documentation",{"href":1525,"dataGaName":1526,"dataGaLocation":1343},"https://docs.gitlab.com/","product documentation",{"text":1528,"config":1529},"Best practice videos",{"href":1530,"dataGaName":1531,"dataGaLocation":1343},"/getting-started-videos/","best practice videos",{"text":1533,"config":1534},"Integrations",{"href":1535,"dataGaName":1536,"dataGaLocation":1343},"/integrations/","integrations",{"title":1538,"items":1539},"Discover",[1540,1545,1550,1555,1559],{"text":1541,"config":1542},"Customer success stories",{"href":1543,"dataGaName":1544,"dataGaLocation":1343},"/customers/","customer success stories",{"text":1546,"config":1547},"Blog",{"href":1548,"dataGaName":1549,"dataGaLocation":1343},"/blog/","blog",{"text":1551,"config":1552},"Demo Hub",{"href":1553,"dataGaName":1554,"dataGaLocation":1343},"/demo-hub/","demo hub",{"text":1556,"config":1557},"The Source",{"href":1558,"dataGaName":1549,"dataGaLocation":1343},"/the-source/",{"text":1560,"config":1561},"Remote",{"href":1562,"dataGaName":1563,"dataGaLocation":1343},"https://handbook.gitlab.com/handbook/company/culture/all-remote/","remote",{"title":1565,"items":1566},"Connect",[1567,1572,1577,1582,1587,1592],{"text":1568,"config":1569},"GitLab Services",{"href":1570,"dataGaName":1571,"dataGaLocation":1343},"/services/","services",{"text":1573,"config":1574},"Contribute",{"href":1575,"dataGaName":1576,"dataGaLocation":1343},"https://contributors.gitlab.com","contribute",{"text":1578,"config":1579},"Community",{"href":1580,"dataGaName":1581,"dataGaLocation":1343},"/community/","community",{"text":1583,"config":1584},"Forum",{"href":1585,"dataGaName":1586,"dataGaLocation":1343},"https://forum.gitlab.com/","forum",{"text":1588,"config":1589},"Events",{"href":1590,"dataGaName":1591,"dataGaLocation":1343},"/events/","events",{"text":1593,"config":1594},"Partners",{"href":1595,"dataGaName":1596,"dataGaLocation":1343},"/partners/","partners",{"config":1598,"title":1601,"text":1602,"link":1603},{"background":1599,"textColor":1600},"url('https://res.cloudinary.com/about-gitlab-com/image/upload/v1777322348/qpq8yrgn8knii57omj0c.png')","#000","What’s new in GitLab","Stay updated with our latest features and improvements.",{"text":1604,"config":1605},"Read the latest",{"href":1606,"dataGaName":1607,"dataGaLocation":1343},"/whats-new/","whats new",{"text":1609,"config":1610,"menu":1612},"Company",{"dataNavLevelOne":1611},"company",{"type":1394,"columns":1613},[1614],{"items":1615},[1616,1621,1627,1629,1634,1639,1644,1649,1654,1659],{"text":1617,"config":1618},"About",{"href":1619,"dataGaName":1620,"dataGaLocation":1343},"/company/","about",{"text":1622,"config":1623,"footerGa":1626},"Jobs",{"href":1624,"dataGaName":1625,"dataGaLocation":1343},"/jobs/","jobs",{"dataGaName":1625},{"text":1588,"config":1628},{"href":1590,"dataGaName":1591,"dataGaLocation":1343},{"text":1630,"config":1631},"Leadership",{"href":1632,"dataGaName":1633,"dataGaLocation":1343},"/company/team/e-group/","leadership",{"text":1635,"config":1636},"Handbook",{"href":1637,"dataGaName":1638,"dataGaLocation":1343},"https://handbook.gitlab.com/","handbook",{"text":1640,"config":1641},"Investor relations",{"href":1642,"dataGaName":1643,"dataGaLocation":1343},"https://ir.gitlab.com/overview/default.aspx","investor relations",{"text":1645,"config":1646},"Trust Center",{"href":1647,"dataGaName":1648,"dataGaLocation":1343},"/security/","trust center",{"text":1650,"config":1651},"AI Transparency Center",{"href":1652,"dataGaName":1653,"dataGaLocation":1343},"/ai-transparency-center/","ai transparency center",{"text":1655,"config":1656},"Newsletter",{"href":1657,"dataGaName":1658,"dataGaLocation":1343},"/company/contact/#contact-forms","newsletter",{"text":1660,"config":1661},"Press",{"href":1662,"dataGaName":1663,"dataGaLocation":1343},"/press/","press",{"text":1665,"config":1666,"menu":1667},"Contact us",{"dataNavLevelOne":1611},{"type":1394,"columns":1668},[1669],{"items":1670},[1671,1676,1681],{"text":1672,"config":1673},"Talk to sales",{"href":1674,"dataGaName":1675,"dataGaLocation":1343},"/sales/","talk to sales",{"text":1677,"config":1678},"Support portal",{"href":1679,"dataGaName":1680,"dataGaLocation":1343},"https://support.gitlab.com/hc/en-us","support portal",{"text":1682,"config":1683},"Customer portal",{"href":1684,"dataGaName":1685,"dataGaLocation":1343},"https://customers.gitlab.com/customers/sign_in/","customer portal",{"close":1687,"login":1688,"suggestions":1695},"Close",{"text":1689,"link":1690},"To search repositories and projects, login to",{"text":1691,"config":1692},"gitlab.com",{"href":1357,"dataGaName":1693,"dataGaLocation":1694},"search login","search",{"text":1696,"default":1697},"Suggestions",[1698,1700,1704,1706,1710,1714],{"text":1374,"config":1699},{"href":1379,"dataGaName":1374,"dataGaLocation":1694},{"text":1701,"config":1702},"Code Suggestions (AI)",{"href":1703,"dataGaName":1701,"dataGaLocation":1694},"/solutions/code-suggestions/",{"text":1410,"config":1705},{"href":1412,"dataGaName":1410,"dataGaLocation":1694},{"text":1707,"config":1708},"GitLab on AWS",{"href":1709,"dataGaName":1707,"dataGaLocation":1694},"/partners/technology-partners/aws/",{"text":1711,"config":1712},"GitLab on Google Cloud",{"href":1713,"dataGaName":1711,"dataGaLocation":1694},"/partners/technology-partners/google-cloud-platform/",{"text":1715,"config":1716},"Why GitLab?",{"href":1387,"dataGaName":1715,"dataGaLocation":1694},{"freeTrial":1718,"mobileIcon":1723,"desktopIcon":1728,"secondaryButton":1731},{"text":1719,"config":1720},"Start free trial",{"href":1721,"dataGaName":1348,"dataGaLocation":1722},"https://gitlab.com/-/trials/new/","nav",{"altText":1724,"config":1725},"Gitlab Icon",{"src":1726,"dataGaName":1727,"dataGaLocation":1722},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1758203874/jypbw1jx72aexsoohd7x.svg","gitlab icon",{"altText":1724,"config":1729},{"src":1730,"dataGaName":1727,"dataGaLocation":1722},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1758203875/gs4c8p8opsgvflgkswz9.svg",{"text":1732,"config":1733},"Get Started",{"href":1734,"dataGaName":1735,"dataGaLocation":1722},"https://gitlab.com/-/trial_registrations/new?glm_source=about.gitlab.com/get-started/","get started",{"freeTrial":1737,"mobileIcon":1741,"desktopIcon":1743},{"text":1738,"config":1739},"Learn more about GitLab Duo",{"href":1379,"dataGaName":1740,"dataGaLocation":1722},"gitlab duo",{"altText":1724,"config":1742},{"src":1726,"dataGaName":1727,"dataGaLocation":1722},{"altText":1724,"config":1744},{"src":1730,"dataGaName":1727,"dataGaLocation":1722},{"button":1746,"mobileIcon":1751,"desktopIcon":1753},{"text":1747,"config":1748},"/switch",{"href":1749,"dataGaName":1750,"dataGaLocation":1722},"#contact","switch",{"altText":1724,"config":1752},{"src":1726,"dataGaName":1727,"dataGaLocation":1722},{"altText":1724,"config":1754},{"src":1755,"dataGaName":1727,"dataGaLocation":1722},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1773335277/ohhpiuoxoldryzrnhfrh.png",{"freeTrial":1757,"mobileIcon":1762,"desktopIcon":1764},{"text":1758,"config":1759},"Back to pricing",{"href":1492,"dataGaName":1760,"dataGaLocation":1722,"icon":1761},"back to pricing","GoBack",{"altText":1724,"config":1763},{"src":1726,"dataGaName":1727,"dataGaLocation":1722},{"altText":1724,"config":1765},{"src":1730,"dataGaName":1727,"dataGaLocation":1722},{"title":1767,"titleMobile":1768,"button":1769,"config":1774},"Duo Agent Platform delivers 400% ROI, per new Forrester Consulting study.","400% ROI: Forrester TEI for GitLab Duo",{"text":1385,"config":1770},{"href":1771,"dataGaName":1772,"dataGaLocation":1773},"https://about.gitlab.com/blog/gitlab-duo-agent-platform-delivers-400-percent-roi/","forrester-tei-dap-banner","global-banner",{"layout":1775,"disabled":1323},"release",{"data":1777},{"text":1778,"source":1779,"edit":1785,"contribute":1790,"config":1795,"items":1800,"minimal":2010},"Git is a trademark of Software Freedom Conservancy and our use of 'GitLab' is under license",{"text":1780,"config":1781},"View page source",{"href":1782,"dataGaName":1783,"dataGaLocation":1784},"https://gitlab.com/gitlab-com/marketing/digital-experience/about-gitlab-com/","page source","footer",{"text":1786,"config":1787},"Edit this page",{"href":1788,"dataGaName":1789,"dataGaLocation":1784},"https://gitlab.com/gitlab-com/marketing/digital-experience/about-gitlab-com/-/blob/main/content/","web ide",{"text":1791,"config":1792},"Please contribute",{"href":1793,"dataGaName":1794,"dataGaLocation":1784},"https://gitlab.com/gitlab-com/marketing/digital-experience/about-gitlab-com/-/blob/main/CONTRIBUTING.md/","please contribute",{"twitter":1796,"facebook":1797,"youtube":1798,"linkedin":1799},"https://twitter.com/gitlab","https://www.facebook.com/gitlab","https://www.youtube.com/channel/UCnMGQ8QHMAnVIsI3xJrihhg","https://www.linkedin.com/company/gitlab-com",[1801,1848,1902,1946,1978],{"title":1490,"links":1802,"subMenu":1817},[1803,1807,1812],{"text":1804,"config":1805},"View plans",{"href":1492,"dataGaName":1806,"dataGaLocation":1784},"view plans",{"text":1808,"config":1809},"Why Premium?",{"href":1810,"dataGaName":1811,"dataGaLocation":1784},"/pricing/premium/","why premium",{"text":1813,"config":1814},"Why Ultimate?",{"href":1815,"dataGaName":1816,"dataGaLocation":1784},"/pricing/ultimate/","why ultimate",[1818],{"title":1819,"links":1820},"Contact Us",[1821,1824,1826,1828,1833,1838,1843],{"text":1822,"config":1823},"Contact sales",{"href":1674,"dataGaName":1353,"dataGaLocation":1784},{"text":1677,"config":1825},{"href":1679,"dataGaName":1680,"dataGaLocation":1784},{"text":1682,"config":1827},{"href":1684,"dataGaName":1685,"dataGaLocation":1784},{"text":1829,"config":1830},"Status",{"href":1831,"dataGaName":1832,"dataGaLocation":1784},"https://status.gitlab.com/","status",{"text":1834,"config":1835},"Terms of use",{"href":1836,"dataGaName":1837,"dataGaLocation":1784},"/terms/","terms of use",{"text":1839,"config":1840},"Privacy statement",{"href":1841,"dataGaName":1842,"dataGaLocation":1784},"/privacy/","privacy statement",{"text":1844,"config":1845},"Cookie preferences",{"dataGaName":1846,"dataGaLocation":1784,"id":1847,"isOneTrustButton":586},"cookie preferences","ot-sdk-btn",{"title":1390,"links":1849,"subMenu":1858},[1850,1854],{"text":1851,"config":1852},"DevSecOps platform",{"href":1372,"dataGaName":1853,"dataGaLocation":1784},"devsecops platform",{"text":1855,"config":1856},"AI-Assisted Development",{"href":1379,"dataGaName":1857,"dataGaLocation":1784},"ai-assisted development",[1859],{"title":1860,"links":1861},"Topics",[1862,1867,1872,1877,1882,1887,1892,1897],{"text":1863,"config":1864},"CICD",{"href":1865,"dataGaName":1866,"dataGaLocation":1784},"/topics/ci-cd/","cicd",{"text":1868,"config":1869},"GitOps",{"href":1870,"dataGaName":1871,"dataGaLocation":1784},"/topics/gitops/","gitops",{"text":1873,"config":1874},"DevOps",{"href":1875,"dataGaName":1876,"dataGaLocation":1784},"/topics/devops/","devops",{"text":1878,"config":1879},"Version Control",{"href":1880,"dataGaName":1881,"dataGaLocation":1784},"/topics/version-control/","version control",{"text":1883,"config":1884},"DevSecOps",{"href":1885,"dataGaName":1886,"dataGaLocation":1784},"/topics/devsecops/","devsecops",{"text":1888,"config":1889},"Cloud Native",{"href":1890,"dataGaName":1891,"dataGaLocation":1784},"/topics/cloud-native/","cloud native",{"text":1893,"config":1894},"AI for Coding",{"href":1895,"dataGaName":1896,"dataGaLocation":1784},"/topics/devops/ai-for-coding/","ai for coding",{"text":1898,"config":1899},"Agentic AI",{"href":1900,"dataGaName":1901,"dataGaLocation":1784},"/topics/agentic-ai/","agentic ai",{"title":1903,"links":1904},"Solutions",[1905,1907,1909,1914,1918,1921,1925,1928,1930,1933,1936,1941],{"text":1434,"config":1906},{"href":1429,"dataGaName":1434,"dataGaLocation":1784},{"text":1423,"config":1908},{"href":1406,"dataGaName":1407,"dataGaLocation":1784},{"text":1910,"config":1911},"Agile development",{"href":1912,"dataGaName":1913,"dataGaLocation":1784},"/solutions/agile-delivery/","agile delivery",{"text":1915,"config":1916},"SCM",{"href":1419,"dataGaName":1917,"dataGaLocation":1784},"source code management",{"text":1863,"config":1919},{"href":1412,"dataGaName":1920,"dataGaLocation":1784},"continuous integration & delivery",{"text":1922,"config":1923},"Value stream management",{"href":1462,"dataGaName":1924,"dataGaLocation":1784},"value stream management",{"text":1868,"config":1926},{"href":1927,"dataGaName":1871,"dataGaLocation":1784},"/solutions/gitops/",{"text":1472,"config":1929},{"href":1475,"dataGaName":1476,"dataGaLocation":1784},{"text":1931,"config":1932},"Small business",{"href":1481,"dataGaName":1482,"dataGaLocation":1784},{"text":1934,"config":1935},"Public sector",{"href":1487,"dataGaName":1488,"dataGaLocation":1784},{"text":1937,"config":1938},"Education",{"href":1939,"dataGaName":1940,"dataGaLocation":1784},"/solutions/education/","education",{"text":1942,"config":1943},"Financial services",{"href":1944,"dataGaName":1945,"dataGaLocation":1784},"/solutions/finance/","financial services",{"title":1495,"links":1947},[1948,1950,1952,1954,1957,1959,1962,1964,1966,1968,1970,1972,1974,1976],{"text":1508,"config":1949},{"href":1510,"dataGaName":1511,"dataGaLocation":1784},{"text":1513,"config":1951},{"href":1515,"dataGaName":1516,"dataGaLocation":1784},{"text":1518,"config":1953},{"href":1520,"dataGaName":1521,"dataGaLocation":1784},{"text":1523,"config":1955},{"href":1525,"dataGaName":1956,"dataGaLocation":1784},"docs",{"text":1546,"config":1958},{"href":1548,"dataGaName":1549,"dataGaLocation":1784},{"text":1960,"config":1961},"What's new",{"href":1606,"dataGaName":1607,"dataGaLocation":1784},{"text":1541,"config":1963},{"href":1543,"dataGaName":1544,"dataGaLocation":1784},{"text":1560,"config":1965},{"href":1562,"dataGaName":1563,"dataGaLocation":1784},{"text":1568,"config":1967},{"href":1570,"dataGaName":1571,"dataGaLocation":1784},{"text":1573,"config":1969},{"href":1575,"dataGaName":1576,"dataGaLocation":1784},{"text":1578,"config":1971},{"href":1580,"dataGaName":1581,"dataGaLocation":1784},{"text":1583,"config":1973},{"href":1585,"dataGaName":1586,"dataGaLocation":1784},{"text":1588,"config":1975},{"href":1590,"dataGaName":1591,"dataGaLocation":1784},{"text":1593,"config":1977},{"href":1595,"dataGaName":1596,"dataGaLocation":1784},{"title":1609,"links":1979},[1980,1982,1984,1986,1988,1990,1994,1999,2001,2003,2005],{"text":1617,"config":1981},{"href":1619,"dataGaName":1611,"dataGaLocation":1784},{"text":1622,"config":1983},{"href":1624,"dataGaName":1625,"dataGaLocation":1784},{"text":1630,"config":1985},{"href":1632,"dataGaName":1633,"dataGaLocation":1784},{"text":1635,"config":1987},{"href":1637,"dataGaName":1638,"dataGaLocation":1784},{"text":1640,"config":1989},{"href":1642,"dataGaName":1643,"dataGaLocation":1784},{"text":1991,"config":1992},"Sustainability",{"href":1993,"dataGaName":1991,"dataGaLocation":1784},"/sustainability/",{"text":1995,"config":1996},"Diversity, inclusion and belonging (DIB)",{"href":1997,"dataGaName":1998,"dataGaLocation":1784},"/diversity-inclusion-belonging/","Diversity, inclusion and belonging",{"text":1645,"config":2000},{"href":1647,"dataGaName":1648,"dataGaLocation":1784},{"text":1655,"config":2002},{"href":1657,"dataGaName":1658,"dataGaLocation":1784},{"text":1660,"config":2004},{"href":1662,"dataGaName":1663,"dataGaLocation":1784},{"text":2006,"config":2007},"Modern Slavery Transparency Statement",{"href":2008,"dataGaName":2009,"dataGaLocation":1784},"https://handbook.gitlab.com/handbook/legal/modern-slavery-act-transparency-statement/","modern slavery transparency statement",{"items":2011},[2012,2015,2018],{"text":2013,"config":2014},"Terms",{"href":1836,"dataGaName":1837,"dataGaLocation":1784},{"text":2016,"config":2017},"Cookies",{"dataGaName":1846,"dataGaLocation":1784,"id":1847,"isOneTrustButton":586},{"text":2019,"config":2020},"Privacy",{"href":1841,"dataGaName":1842,"dataGaLocation":1784},[2022],{"id":2023,"title":2024,"body":1322,"config":2025,"content":2027,"description":1322,"extension":2031,"meta":2032,"navigation":586,"path":2033,"seo":2034,"stem":2035,"__hash__":2036},"blogAuthors/en-us/blog/authors/pj-metz.yml","Pj Metz",{"template":2026},"BlogAuthor",{"name":7,"config":2028},{"headshot":2029,"ctfId":2030},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1749659488/Blog/Author%20Headshots/gitlab-logo-extra-whitespace.png","PjMetz","yml",{},"/en-us/blog/authors/pj-metz",{},"en-us/blog/authors/pj-metz","SgW84Gu-lPq0zFzhy1aT23bZjx9kWViDG_WXzCPn04E",[2038,2046,2052],{"title":2039,"description":2040,"heroImage":2041,"category":1318,"date":2042,"authors":2043,"slug":2045,"externalUrl":1322},"Shadow programs give employees a peek into leadership roles","Shadow programs are a great resource if you’re looking to explore new roles, expand your skill set, or learn how decisions are made.","https://res.cloudinary.com/about-gitlab-com/image/upload/v1749683055/Blog/Hero%20Images/ideaabstract.jpg","2023-07-17",[2044],"Fatima Sarah Khalid","benefits-of-corporate-shadow-programs",{"title":2047,"description":2048,"heroImage":1324,"category":1318,"date":2049,"authors":2050,"slug":2051,"externalUrl":1322},"Learn Python with Pj! Part 5 - Build a hashtag tracker with the Twitter API","Our Education Evangelist Pj Metz wraps up his five-part series with this penultimate tutorial.","2022-06-01",[7],"learn-python-with-pj-part-5-building-something-with-the-twitter-api",{"title":2053,"description":2054,"heroImage":2055,"category":1318,"date":2056,"authors":2057,"slug":2059,"externalUrl":1322},"5 ways collaboration boosts productivity and your career","Collaboration is a powerful tool and DevOps pros that learn how to master it will expand their growth opportunities.","https://res.cloudinary.com/about-gitlab-com/image/upload/v1749668473/Blog/Hero%20Images/john-schnobrich-FlPc9_VocJ4-unsplash.jpg","2022-05-02",[2058],"Sharon Gaudin","5-ways-collaboration-boosts-productivity-and-your-career",{"promotions":2061},[2062,2076,2088,2100],{"id":2063,"categories":2064,"header":2066,"text":2067,"button":2068,"image":2073},"ai-modernization",[2065],"ai","Is AI achieving its promise at scale?","Quiz will take 5 minutes or less",{"text":2069,"config":2070},"Get your AI maturity score",{"href":2071,"dataGaName":2072,"dataGaLocation":1549},"/assessments/ai-modernization-assessment/","modernization assessment",{"config":2074},{"src":2075},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1772138786/qix0m7kwnd8x2fh1zq49.png",{"id":2077,"categories":2078,"header":2080,"text":2067,"button":2081,"image":2085},"devops-modernization",[2079,1886],"product","Are you just managing tools or shipping innovation?",{"text":2082,"config":2083},"Get your DevOps maturity score",{"href":2084,"dataGaName":2072,"dataGaLocation":1549},"/assessments/devops-modernization-assessment/",{"config":2086},{"src":2087},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1772138785/eg818fmakweyuznttgid.png",{"id":2089,"categories":2090,"header":2092,"text":2067,"button":2093,"image":2097},"security-modernization",[2091],"security","Are you trading speed for security?",{"text":2094,"config":2095},"Get your security maturity score",{"href":2096,"dataGaName":2072,"dataGaLocation":1549},"/assessments/security-modernization-assessment/",{"config":2098},{"src":2099},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1772138786/p4pbqd9nnjejg5ds6mdk.png",{"id":2101,"paths":2102,"header":2105,"text":2106,"button":2107,"image":2112},"github-azure-migration",[2103,2104],"migration-from-azure-devops-to-gitlab","integrating-azure-devops-scm-and-gitlab","Is your team ready for GitHub's Azure move?","GitHub is already rebuilding around Azure. Find out what it means for you.",{"text":2108,"config":2109},"See how GitLab compares to GitHub",{"href":2110,"dataGaName":2111,"dataGaLocation":1549},"/compare/gitlab-vs-github/github-azure-migration/","github azure migration",{"config":2113},{"src":2087},{"header":2115,"blurb":2116,"button":2117,"secondaryButton":2122},"Start building faster today","See what your team can do with the intelligent orchestration platform for DevSecOps.\n",{"text":2118,"config":2119},"Get your free trial",{"href":2120,"dataGaName":1348,"dataGaLocation":2121},"https://gitlab.com/-/trial_registrations/new?glm_content=default-saas-trial&glm_source=about.gitlab.com/","feature",{"text":1822,"config":2123},{"href":1674,"dataGaName":1353,"dataGaLocation":2121},1786803735940]